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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Accessing the new DataRow in GDBG

Thread ID:

Created:

Updated:

Platform:

Replies:

2640 Feb 6,2003 02:06 PM UTC Mar 22,2003 11:31 PM UTC WinForms 5
loading
Tags: GridControl
Thomas Zueger
Asked On February 6, 2003 02:06 PM UTC

Hi, I need to access to the new DataRow when adding a new row to the grid. This have to be before the Binder.EndEdit() method is called(e.g. leaving the added row in the grid). Regards Thomas

Administrator [Syncfusion]
Replied On February 6, 2003 07:44 PM UTC

You might try the EditModeChanged event of GridModelDataBinder. This is called for every row when the user starts editing the row but you can check if the edited record is the last record; this.gridDataBoundGrid1.Binder.EditModeChanged += new EventHandler(BinderEditModeChanged); void BinderEditModeChanged(object sender, EventArgs e) { CurrencyManager cm = sender as CurrencyManager; if (this.gridDataBoundGrid1.Binder.IsEditing && this.gridDataBoundGrid1.Binder.RecordCount-1 == this.gridDataBoundGrid1.Binder.CurrentPosition) System.Diagnostics.Trace.WriteLine("Add New" + this.gridDataBoundGrid1.Binder.RecordCount.ToString()); } Stefan

Thomas Zueger
Replied On February 7, 2003 05:11 PM UTC

Stefan, The code you posted does not work, bacause the sender is a type of Syncfusion.Windows.Forms.Grid.GridModelDataBinder. I'm changing the code to: void BinderEditModeChanged(object sender, EventArgs e) { Syncfusion.Windows.Forms.Grid.GridModelDataBinder binder = sender as Syncfusion.Windows.Forms.Grid.GridModelDataBinder; CurrencyManager cm = (CurrencyManager)binder.BindingContext[this.gridDataBoundGrid1.DataSource, this.gridDataBoundGrid1.DataMember]; if (this.gridDataBoundGrid1.Binder.IsEditing && this.gridDataBoundGrid1.Binder.RecordCount-1 == this.gridDataBoundGrid1.Binder.CurrentPosition) System.Diagnostics.Trace.WriteLine("Add New" + this.gridDataBoundGrid1.Binder.RecordCount.ToString()); } Regards Thomas

Ken Law
Replied On March 16, 2003 04:04 PM UTC

The problem with this method is that it doesn't guarantee you have a new row because conditions are the same when you re-edit the last row (you can't set a default value again - the user may have changed it during the initial edit). I've been very frustrated trying to do something that should be extremely simple. Setting default values in new rows. Using RowEditing or RowEnter is a problem because the datasource does not yet have a record to edit. Trying to set the CellValue just doesn't work (no effect). There really should be a default value property in GridBoundColumn.StyleInfo to avoid even having to write code. Otherwise, there should be a NewRow event so default values can be set. This is the most basic of needs.

Sean Greer
Replied On March 19, 2003 09:23 PM UTC

While the GridBoundColumn does not have a DefaultValue property, the DataColumn class does. Can you not set the default value in this way? HTH, Sean

Ken Law
Replied On March 22, 2003 11:31 PM UTC

I can't set the default in the DataColumn because the default value depends on which of several GDBGs is editing the data. Each grid sets this default value which serves as a filter value for the DataView attached to the particular grid. The ideal solution would be a NewRow event that happens when the underlying data source adds a row. Then defaults could be reliably set based on virtually any criteria.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;