Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to read a cell in a datagrid (winform)

0 views
Skip to first unread message

Jeff Foster

unread,
Dec 10, 2002, 12:47:30 PM12/10/02
to
Hello,

I'm trying to read a cell in a winform datagrid. I've tried using the
Current Row property to look back into the dataset, and that works... until
the datagrid is sorted, then the indexes no longer match.

Any ideas?

Thanks,
Jeff Foster

Mickey Williams

unread,
Dec 10, 2002, 1:24:11 PM12/10/02
to

"Jeff Foster" <je...@step4.com> wrote in message
news:uOvqzQHoCHA.2408@TK2MSFTNGP12...

> I'm trying to read a cell in a winform datagrid. I've tried using the
> Current Row property to look back into the dataset, and that works...
until
> the datagrid is sorted, then the indexes no longer match.

You need to wrok with the binding manager - the grid is just a viewport over
a portion of the data.

BindingManagerBase bm =
(BindingManagerBase)grid.BindingContext[grid.DataSource, grid.DataMember];
DataRowView view = (DataRowView)bm.Current;
DataRow row = view.Row;

--
Mickey Williams
Author, "Microsoft Visual C# .NET", Microsoft Press


Jeff Foster

unread,
Dec 10, 2002, 1:40:27 PM12/10/02
to
That works perfect, Thanks!

"Mickey Williams" <m...@codevtech.com> wrote in message
news:OJgpAnHoCHA.2408@TK2MSFTNGP11...

0 new messages