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

CurrenCell change event in gridGroupingControl

Hi, I want to capture the cell value whenever there is a change in the cell value. which event is better to use either: this.gridgroupingControl.TableControlCurrentCellChanged or this.gridgroupingControl.TableControlCurrentCellChanging. Thanks, prathima

6 Replies

AD Administrator Syncfusion Team August 2, 2005 04:11 AM

The Changing event is only raised once (on the first change by your user to the cell). It will not be raised again until teh user leaves the cell, then returns to teh cell, and starts to make another change to teh cell. If you want to catch evey (intermediate) change, then the TableControlCurrentCellChanged event is better.


PV Prathima Venkobachar August 2, 2005 04:30 AM

Thanks, How can I get the current cell changed value..? If the current cell is "price", I want to set this value to another column in the grid. How can I do this..? Thanks, Prathima


AD Administrator Syncfusion Team August 2, 2005 05:02 AM

To do what you described, I would suggest using TableControlCurrentCellValidating. This is hit once as your user leaves the cell. This code will then copy teh value in ParentName to the ParentDec column.
private void gridGroupingControl1_TableControlCurrentCellValidating(object sender, GridTableControlCancelEventArgs e)
{
	GridCurrentCell cc = e.TableControl.CurrentCell;
	GridTableCellStyleInfo style = e.TableControl.Model[cc.RowIndex, cc.ColIndex] as GridTableCellStyleInfo;
	if (style.TableCellIdentity.Column != null &&
		style.TableCellIdentity.Column.MappingName == "ParentName" &&
		(style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell ||
		style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell))
	{
		string newvalue = cc.Renderer.ControlText;
		GridRecordRow rr = style.TableCellIdentity.DisplayElement as GridRecordRow;

		rr.ParentRecord.SetValue("ParentDec", newvalue);
	}
}


PV Prathima Venkobachar August 2, 2005 06:30 AM

I want to do this as and when the user changes the cell value. It is not necessary the user leaves the columns. Is it better for me to use TableControlcellChanging event. Thanks, Prathima


AD Administrator Syncfusion Team August 2, 2005 07:26 AM

TableControlCurrentCellChanged is where you can catch each change by your user. You will also have to make sure the row id redrawn so you change to the other column is displayed imeddiately.
private void gridGroupingControl1_TableControlCurrentCellChanged(object sender, GridTableControlEventArgs e)
{
	GridCurrentCell cc = e.TableControl.CurrentCell;
	GridTableCellStyleInfo style = e.TableControl.Model[cc.RowIndex, cc.ColIndex] as GridTableCellStyleInfo;
	if (style.TableCellIdentity.Column != null &&
		style.TableCellIdentity.Column.MappingName == "ParentName" &&
		(style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell ||
		style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell))
	{
		string newvalue = cc.Renderer.ControlText;
		GridRecordRow rr = style.TableCellIdentity.DisplayElement as GridRecordRow;

		rr.ParentRecord.SetValue("ParentDec", newvalue);
		e.TableControl.RefreshRange(GridRangeInfo.Row(cc.RowIndex));
	}
}


PV Prathima Venkobachar August 2, 2005 07:43 AM

It works fine. Thanks a lot for ur G8 help.. Prathima

Loader.
Live Chat Icon For mobile
Up arrow icon