get the index of a new row in a datagrid

  • Thread starter Thread starter Hugh Mungo
  • Start date Start date
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
 
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.
 
Back
Top