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

CheckBoxClick event or CurrentCellChanged event

Thread ID:





33980 Aug 30,2005 02:39 PM UTC Nov 30,2005 11:11 PM UTC WinForms 5
Tags: GridControl
Najmeh Joze-khajavi
Asked On August 30, 2005 02:39 PM UTC

Here is the scenario and I am not sure which event (CheckBoxClick or CurrentCellChanged) is the right one to use. I have a grid control that has two check boxes. These check boxes suppose to do totally different things. When click in one of them it suppose to display two hidden columns and the other one suppose to change some coloring. CheckBoxClick event is for grid therefore I need to know which checkbox has changed to do the proper action. I thought of CurrentCell.RowIndex and CurrentCell.ColIndex. But for first time when I click on the checkbox the RowIndex and ColIndex returns -1, -1. The second time it returns the correct position. How can I fix this? Should I use CurrentCellChanged instead?

Administrator [Syncfusion]
Replied On August 30, 2005 03:21 PM UTC

What kind of grid are you using? Why can you not use gridControl1.CheckBoxClick or gridGroupingControl1.TableControlCheckBoxClick or gridDataBoundGrid1.CheckBoxClick?

Najmeh Joze-khajavi
Replied On August 30, 2005 05:08 PM UTC

I am using GridControl. When I said CheckBoxClick event I meant the same as gridControl1.CheckBoxClick. Since I have two check boxes I need to know which checkbox has been checked by user. Therefore I need to know the row and column of the checkbox. I found out how I can get the row and column. I used e.RowIndex and e.ColIndex. private void _WorksheetGrid_CheckBoxClick(object sender, GridCellClickEventArgs e) { GridStyleInfo style; GridControl grid = sender as GridControl; if (grid != null) { if (e.RowIndex == 1 && e.ColIndex ==5 ) //Show Prefault { .... } if (e.RowIndex == 14 && e.ColIndex == 11 ) { ... } ... }

Replied On November 29, 2005 09:57 PM UTC

Actually, Clay, Najmeh''s question raises an important question - is there something broken about the CurrentCellChanged event w/r/t checkboxes?? Inside that event, I am seeing what seems to be inconsistent behavior. If the cell firing the event is a textbox, grid.CurrentCell().GetRenderer().GetCellValue() returns the correct "new value" in the text box. If, however, the cell that changed is a checkbox, GetRenderer().GetCellValue() ~always~ returns true. Could this be correct?

Administrator [Syncfusion]
Replied On November 30, 2005 12:45 AM UTC

This is actually by design. The CheckBox CellType is special. It has no active cell control and the checkbox is drawn in a static manner. There is no Control used to render this cell. The values are immediately stored in the grid as they are changed. Here is code that shows how to get this current value in CurrentCellChanged.
private void gridControl1_CurrentCellChanged(object sender, EventArgs e)
	GridCurrentCell cc = this.gridControl1.CurrentCell;
	if(this.gridControl1[cc.RowIndex, cc.ColIndex].CellType == "CheckBox")
		Console.WriteLine(this.gridControl1[cc.RowIndex, cc.ColIndex].CellValue);

Replied On November 30, 2005 11:11 PM UTC

Clay, Thanks for confirming this behavior is by design. I had already figured out to use grid[r,c].cellvalue - but I wasn''t sure this was by intent, or just a convenient hack. -ralph


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

or the page will be automatically redirected to 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