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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Handling cell text change

Thread ID:





94891 Jun 8,2010 03:32 PM UTC Jun 9,2010 09:04 AM UTC WinForms 2
Tags: Grouping
Jim Tench
Asked On June 8, 2010 03:32 PM UTC

I have a gridGroupingControl bound to a list of objects. When a user edits or adds a new record, I want to be able to review the contents of a specific cell as the tab away (press enter, mouse click, whatever) from the cell and change the contents of the cell. I want this to happen before the record is updated/added in the underlaying data.

I'm sure there outght to be an event that allows me to do that and I thought it ought to be the validate one, but that doesn't seem to let me access the cell.value.

Help please, a pointer or 2!



Jim Tench
Replied On June 8, 2010 04:02 PM UTC

RecordvalueChanging Event says - Occurs when a RecordFieldCell's value is changed and before Record.SetValue is Called, No it isn't! I've implemented that like the following -
private void OnRecordValueChanging(object sender, RecordValueChangingEventArgs e)
if (e.FieldDescriptor.Name == "B")
Element el = gridGroupingControl1.Table.GetInnerMostCurrentElement();
GridTable table = el.ParentTable as GridTable;
GridTableControl tableControl = gridGroupingControl1.GetTableControl(table.TableDescriptor.Name);
GridCurrentCell cc = tableControl.CurrentCell;
cc.Renderer.ControlValue = "Albert";

Setting a breakpoint on cc.renderer.ControlValue = "Albert" and stepping past it, I can clearly see the ControlValue contains Albert, but hitting F5 and looking at the result in the grid, the data hasn't changed!

That makes no sense what so ever!

Jisha Joy [Syncfusion]
Replied On June 9, 2010 09:04 AM UTC

Hi Jim,

We need to handle TableControlCurrentCellValidating event to done validation on the grid cell before the values are getting committed. The Validating event is the best to handle when you want to validate the contents you entered. You can set e.Cancel to true in this event to indicate validation failed. See the code:

void gridGroupingControl1_TableControlCurrentCellValidating(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCancelEventArgs e)
GridTableCellStyleInfo style = e.TableControl.CurrentCell.Renderer.CurrentStyle as GridTableCellStyleInfo;
if (style.TableCellIdentity.Column != null && style.TableCellIdentity.Column.Name == "Item")
if (e.TableControl.Table.CurrentRecord.Kind != DisplayElementKind.AddNewRecord)// Check for AddNewRecord
GridCurrentCell cc = e.TableControl.CurrentCell;

if (cc.Renderer.ControlText == "wrong") // check for the desired value

MessageBox.Show("Not a valid value");
e.Inner.Cancel = true;




Sample for your reference:


Please let me know if this helps.



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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