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

CurrentCellChanging / CurrentCellChanged

Thread ID:

Created:

Updated:

Platform:

Replies:

30997 Jun 28,2005 07:29 PM UTC Jun 30,2005 07:07 PM UTC Windows Forms 7
loading
Tags: GridControl
Tim Aquino
Asked On June 28, 2005 07:29 PM UTC

Hi, We''ve noticed this problem upon upgrading to v3.2.1.0 (from v2.1.0.9). We have a databound grid with a checkbox cell. This is the only ''editable'' column in the grid and the user may check/uncheck this based on a value in another column (ie, amt column must be > 500). If the value in the amt column is > 500, the user may select/unselect the row by checking/unchecking the checkbox, otherwise the program cancels the action in the _CurrentCellChanging event. The event _CurrentCellChanging is triggered ONLY when the user moves from a different cell to the checkbox cell. If the current cell is already the checkbox cell, the event is no longer triggered. How do we fix this problem? Thanks, TA

Administrator [Syncfusion]
Replied On June 28, 2005 07:56 PM UTC

You can handle the CheckBoxClick event. It is a cancelable event.

Tim Aquino
Replied On June 28, 2005 08:06 PM UTC

We used to have the validation in that event. However, the problem with the CheckBoxClick event is that it only responds to mouse clicks, not keypress events (the space key will continue to check/uncheck the checkbox). We don''t want to duplicate the code in the keypress (space) so we decided to use the _CurrentCellChanging and _CurrentCellChanged events. Everything was on v2.1.0.9. >You can handle the CheckBoxClick event. It is a cancelable event.

Tim Aquino
Replied On June 28, 2005 08:12 PM UTC

Hi, I''ve created this dummy program to demonstrate the problem. The _CurrentCellChanging is only triggered when the user moves from another cell. The validation happens in this event ("*** OK ***" will be displayed if the validation is a success). However, when the focus is already on the checkbox cell, this event is not triggered when the user checks/unchecks the box, thus missing the validation routine. thanks, private void Form1_Load(object sender, System.EventArgs e) { #region Get the DataSource DataTable dt = new DataTable("MyTable"); int nCols = 4; int nRows = 10; for(int i = 0; i < nCols; i++) dt.Columns.Add(new DataColumn(string.Format("Col{0}", i))); dt.Columns.Add(new DataColumn("boolValue", typeof(bool))); for(int i = 0; i < nRows; ++i) { DataRow dr = dt.NewRow(); for(int j = 0; j < nCols; j++) if(i % 2 == 0 && j == 3) dr[j] = "VALID"; else dr[j] = string.Format("row{0} col{1}", i, j); dr[nCols] = i % 2 == 0; dt.Rows.Add(dr); } #endregion this.gridDataBoundGrid1.DataSource = dt; } private void gridDataBoundGrid1_CurrentCellChanging(object sender, System.ComponentModel.CancelEventArgs e) { System.Diagnostics.Debug.WriteLine("_CurrentCellChanging"); if(gridDataBoundGrid1[gridDataBoundGrid1.CurrentCell.RowIndex,4].CellValue.ToString() == "VALID") System.Diagnostics.Debug.WriteLine("*** OK ***"); else e.Cancel = true; } private void gridDataBoundGrid1_CurrentCellChanged(object sender, System.EventArgs e) { System.Diagnostics.Debug.WriteLine("_CurrentCellChanged"); } private void gridDataBoundGrid1_CurrentCellValidateString(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellValidateStringEventArgs e) { System.Diagnostics.Debug.WriteLine("_CurrentCellValidateString"); } private void gridDataBoundGrid1_CheckBoxClick(object sender, Syncfusion.Windows.Forms.Grid.GridCellClickEventArgs e) { System.Diagnostics.Debug.WriteLine("_CheckBoxClick"); } private void gridDataBoundGrid1_CurrentCellActivating(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellActivatingEventArgs e) { System.Diagnostics.Debug.WriteLine("_CurrentCellActivating"); e.ColIndex = 5; } private void gridDataBoundGrid1_CurrentCellValidating(object sender, System.ComponentModel.CancelEventArgs e) { System.Diagnostics.Debug.WriteLine("_CurrentCellValidating"); } private void gridDataBoundGrid1_CurrentCellStartEditing(object sender, System.ComponentModel.CancelEventArgs e) { System.Diagnostics.Debug.WriteLine("_CurrentCellStartEditing"); } private void gridDataBoundGrid1_CurrentCellKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { System.Diagnostics.Debug.WriteLine("_CurrentCellKeyPress"); }

Tim Aquino
Replied On June 29, 2005 01:30 PM UTC

any help? thanks, >Hi, > >I''ve created this dummy program to demonstrate the problem. The _CurrentCellChanging is only triggered when the user moves from another cell. The validation happens in this event ("*** OK ***" will be displayed if the validation is a success). However, when the focus is already on the checkbox cell, this event is not triggered when the user checks/unchecks the box, thus missing the validation routine. > >thanks, > > > > > > private void Form1_Load(object sender, System.EventArgs e) > { > #region Get the DataSource > DataTable dt = new DataTable("MyTable"); > > int nCols = 4; > int nRows = 10; > > for(int i = 0; i < nCols; i++) > dt.Columns.Add(new DataColumn(string.Format("Col{0}", i))); > dt.Columns.Add(new DataColumn("boolValue", typeof(bool))); > > for(int i = 0; i < nRows; ++i) > { > DataRow dr = dt.NewRow(); > for(int j = 0; j < nCols; j++) > if(i % 2 == 0 && j == 3) > dr[j] = "VALID"; > else > dr[j] = string.Format("row{0} col{1}", i, j); > dr[nCols] = i % 2 == 0; > dt.Rows.Add(dr); > } > > #endregion > > this.gridDataBoundGrid1.DataSource = dt; > > } > > private void gridDataBoundGrid1_CurrentCellChanging(object sender, System.ComponentModel.CancelEventArgs e) > { > System.Diagnostics.Debug.WriteLine("_CurrentCellChanging"); > if(gridDataBoundGrid1[gridDataBoundGrid1.CurrentCell.RowIndex,4].CellValue.ToString() == "VALID") > System.Diagnostics.Debug.WriteLine("*** OK ***"); > else > e.Cancel = true; > } > > private void gridDataBoundGrid1_CurrentCellChanged(object sender, System.EventArgs e) > { > System.Diagnostics.Debug.WriteLine("_CurrentCellChanged"); > } > > private void gridDataBoundGrid1_CurrentCellValidateString(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellValidateStringEventArgs e) > { > System.Diagnostics.Debug.WriteLine("_CurrentCellValidateString"); > } > > private void gridDataBoundGrid1_CheckBoxClick(object sender, Syncfusion.Windows.Forms.Grid.GridCellClickEventArgs e) > { > System.Diagnostics.Debug.WriteLine("_CheckBoxClick"); > } > > private void gridDataBoundGrid1_CurrentCellActivating(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellActivatingEventArgs e) > { > System.Diagnostics.Debug.WriteLine("_CurrentCellActivating"); > e.ColIndex = 5; > } > > private void gridDataBoundGrid1_CurrentCellValidating(object sender, System.ComponentModel.CancelEventArgs e) > { > System.Diagnostics.Debug.WriteLine("_CurrentCellValidating"); > } > > private void gridDataBoundGrid1_CurrentCellStartEditing(object sender, System.ComponentModel.CancelEventArgs e) > { > System.Diagnostics.Debug.WriteLine("_CurrentCellStartEditing"); > } > > private void gridDataBoundGrid1_CurrentCellKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) > { > System.Diagnostics.Debug.WriteLine("_CurrentCellKeyPress"); > } >

Administrator [Syncfusion]
Replied On June 29, 2005 02:43 PM UTC

Not yet. If you need to do something now, you could try moving your validation code into a helper method, and then call this same method from both CheckBoxClick and CurrentCellKeyPress.

Tim Aquino
Replied On June 29, 2005 06:38 PM UTC

Hi, I think I''ve found a workaround with the problem: 1. I''ve added grid.CurrentCell.CancelEdit() in _CurrentCellChanging if validation fails 2. I''ve added grid.CureentCell.BeginEdit() and grid.CurrentCell.EndEdit() in _CurrentCellChanged. any comments on these codes? thanks, >Not yet. > >If you need to do something now, you could try moving your validation code into a helper method, and then call this same method from both CheckBoxClick and CurrentCellKeyPress.

Administrator [Syncfusion]
Replied On June 30, 2005 07:07 PM UTC

Hi TA, I checked the sample with our latest codebase and it is fixed there. It is related to an issue we had with CurrentCellChanging that also affected other cell types. Your workaround should be fine. But if you want to check it with the latest codebase you can submit a dtrac incident and we''ll send you download instructions for the patch. Stefan >Hi, > >I think I''ve found a workaround with the problem: > >1. I''ve added grid.CurrentCell.CancelEdit() in _CurrentCellChanging if validation fails >2. I''ve added grid.CureentCell.BeginEdit() and grid.CurrentCell.EndEdit() in _CurrentCellChanged. > >any comments on these codes? > >thanks, > > >>Not yet. >> >>If you need to do something now, you could try moving your validation code into a helper method, and then call this same method from both CheckBoxClick and CurrentCellKeyPress.

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

;