We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

GDBG new item event

hi there,
Soo when im using GridDataBoundGrid and set the EnableAddNew property to true, what event should i subscribe to so that i can detect when user adding new item (by writing cell on the last row). So that i can customize the creation of the new item in the collection.


3 Replies

CI Christopher Issac Sunder K Syncfusion Team October 4, 2010 01:33 PM UTC

Hi Nazmi,

Thank you for your interest in Syncfusion products.

You can make use of "SourceListRecordChanging" event to identify when the user added a new record into GridGroupingControl.


this.gridGroupingControl1.SourceListRecordChanging += new RecordChangedEventHandler(gridGroupingControl1_SourceListRecordChanging);

void gridGroupingControl1_SourceListRecordChanging(object sender, RecordChangedEventArgs e)
{
if (e.Action == RecordChangedType.Added)
{
Console.WriteLine("The New Record is : " + e.Record);
Console.WriteLine("New Record Added to index : " + e.NewIndex);
}
}


Please refer the following sample which illustrates the above.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GC_Update390823270.zip

Please let me know if this helps.

Regards,
Christo.



NA nazmi anuar October 7, 2010 07:14 AM UTC

err look like GridDataBoundGrid does not have the same event.
for now i just use the event below..

void DataBoundGridModel_DataProviderSaveCellInfo(...)
{
if (this.Binder.IsAddNew)
{
....
}
}



JJ Jisha Joy Syncfusion Team October 12, 2010 05:45 AM UTC

Hi Nazmi,

You could hook into the CurrencyManager's ListChanged event to track the underlying datasources changes in GridDataBoungGrid. See the code to get the values of the newly added row.



CurrencyManager cm = this.gridDataBoundGrid1.BindingContext[this.gridDataBoundGrid1.DataSource, this.gridDataBoundGrid1.DataMember] as CurrencyManager;
((DataView)cm.List).ListChanged += new ListChangedEventHandler(Form1_ListChanged);

private void Form1_ListChanged(object sender, ListChangedEventArgs e)
{
if(e.ListChangedType == ListChangedType.ItemAdded )
{
DataView dv = sender as DataView;
DataRowView drv = dv[e.NewIndex] as DataRowView;
Console.WriteLine(drv["SNo"]);

}
}




Sample for your reference:

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GDBGData-12528921.zip

Please let me know if this helps.


Jisha


Loader.
Live Chat Icon For mobile
Up arrow icon