get the index of a new row in a datagrid

H

Hugh Mungo

Hi

How can you get the index of a newly added row to a datagrid that is bound
to a dataview
(c# windows forms)

Thanks
 
T

TT \(Tom Tempelaere\)

Hi Hugh,

Hugh Mungo said:
Hi

How can you get the index of a newly added row to a datagrid that is bound
to a dataview
(c# windows forms)

Thanks

This is a post from Dmytro Lapshyn [MVP] on
microsoft.public.dotnet.languages.csharp that I think answers your question
(title: Re: BindingManagerBase.Position and Table.Rows.Find)

Dmytro Lapshyn said:
Hi Christopher,

As you use complex data binding, do the following:

CurrencyManager cm = (CurrencyManager)this.BindingContext[theDataTable];
DataView dv = (DataView)cm.List;

// Search the row in the DataView by its key.
// We need the index of the row in the DataView, not the source DataTable.

cm.Position = foundRowIndex;

Does this answer your question?

Kind regards,
Tom T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top