Re: Detecting a new Datagrid Row

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: ClayB [Syncfusion] (clayb_at_syncfusion.com)
Date: 08/19/04


Date: Thu, 19 Aug 2004 04:27:01 -0400


BlankYou can get the CurrencyManager for the datagrid, and then get its associated dataview, and subscribe to the dataview.ListChanged event. The ListChangedEventArgs will tell your the ListChangedType, and the new / old positions whose values depend on the ListChangedType.

        CurrencyManager cm = (CurrencyManager)this.dataGrid1.BindingContext[dataGrid1.DataSource, datagrid1.DataMember];
        DataView dv = (DataView) cm.List;
        dv.ListChanged += new ListChangedEventHandler(dv_ListChanged);

========================
Clay Burch, .NET MVP

Visit www.syncfusion.com for the coolest tools

  "Paul J. Lay" <pjlay@msn.com> wrote in message news:%23Me8L7XhEHA.2416@TK2MSFTNGP10.phx.gbl...
  I have an app which includes a winform datagrid bound to a dataset. At times a new row is added to the dataset and sometimes the datagrid displays the new row as the last row and other times the row is
  displayed as the first row. My code works great if the new row is displayed last because I can calculate the row index. Is there any way to detect via a datagrid event or other means to locate (get the row index) a newly added row in a datagrid. Thanks for your help.

  Best Regards,

  Paul J. Lay