|
-
Oct 2nd, 2006, 09:09 AM
#1
Thread Starter
Fanatic Member
[Resolved][2.0] Getting DataGridView data
Is there any way to "get" the data displayed in the datagridview control?
The underlying data structure is different for different screens, and I want to use the same data-getting for a handful of datagridviews.
There does not seem to be a straightforward way to navigate the cells to get their values.
Last edited by JPicasso; Oct 3rd, 2006 at 07:20 AM.
Merry Christmas
-
Oct 2nd, 2006, 08:44 PM
#2
Re: [2.0] Getting DataGridView data
The Item property of the DataGridView returns a cell by column name or index and row index. Had you read the help topic for the DataGridView member listing as you should have you'd have seen this description:
Overloaded. Gets or sets the cell located at the intersection of the specified row and column.
Once you've got the cell you want you can access its Value or FormattedValue property. Having said that, if your grid is bound then I'd suggest working with the data source rather than the grid is most situations. If you've bound your grid to a BindingSource, as is recommended, then you can get the bound data from that. If the BindingSource is bound to a DataTable then its items are DataRowView objectsw, from which you can get the data directly or from the corresponding DataRow, which is exposed via its Row property.
-
Oct 3rd, 2006, 07:19 AM
#3
Thread Starter
Fanatic Member
Re: [2.0] Getting DataGridView data
I actually had been in the help section a couple of times, but never picked up on how to get info back out.
I stumbled upon the .rows collection which would have been infinatly more apparent to me if I had recalled that C# uses [] instead of () for indexing items.
It is not a bound data source, and it's a cluster you-know-what to pick out what I need from the Data. Anyways, seems I'm good to go.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|