Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / January 2007

Tip: Looking for answers? Try searching our database.

Is cell[index] the only way to get row data?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Beemer Biker - 29 Jan 2007 16:10 GMT
It is awkard to code up the following:

double dFreq =
Convert.ToDouble(dataGridView1.Rows[CurrentFrequency].Cells[freqDataGridViewTextBoxColumn.Index].Value);

It seems to me (comeing from CBuilder6) that I should be able to specify the
selected row as in

dataGridView1.Rows[CurrentFrequency].Selected = true;

and then get the column values directly from the column identifier  as in
(this does not work)
double freq = freqDataGridViewTextBoxColumn.value;

There is no method or property that I can see in the column identifier.
Even setting a breakpoint right after the CurrentRow is selected I can
search thru that column identifier, or the TableAdapter or the bindingSource
or the DateSet.  ie: I cannot find a "value" that I can access after the row
is selected.  Indexing cell[] works fine, just seems there is a better way
no?

Signature

=======================================================================
Joseph "Beemer  Biker" Stateson
http://ResearchRiders.org     Ask about my 99'R1100RT
=======================================================================

Bart Mermuys - 29 Jan 2007 19:33 GMT
Hi,

> It is awkard to code up the following:
>
[quoted text clipped - 16 lines]
> access after the row is selected.  Indexing cell[] works fine, just seems
> there is a better way no?

There are other ways but not necesairly better, depends ...

* Using BindingSource:

- set current row
someBindingSource.Position =  rowIdx;

- get data from current row:
double freq = (double)((DataRowView)someBindingSource.Current)["freq"];

- get typed DataRow (when using typed DataSets):
SomeTypedDataSet.SomeTypedRow row =
    (SomeTypedDataSet.SomeTypedRow)
    ((DataRowView)someBindingSource.Current).Row;

* Using DataGridView:

- set current row:
dataGridView1.CurrentCell = dataGridView[rowIdx, 0];

- get data from current row
double freq = (double)dataGridView1.CurrentRow.Cells["freq"].Value;

HTH,
Greetings

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.