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
close icon

How to make a DropdownGrid CellType cell editable and force a CheckBox cell update cellValue after click?

Hi,
We are using Syncfusion V4.4.0.51 Windows Forms Grid Control. I have a regular gridControl that have 10 rows and 2 columns. There are two issues with the gridControl:
(1). I have some cells whose cell type is set to DropdownGrid CellType. The problem is once the cell is set to this type, it is not directly editable like a ComboBox cell. Is there a way to make DropdownGrid cell still editable?
(2). I have some cells whose cell type is set to CheckBox CellType. Once it is clicked, the checkbox changes status right away and the CheckBoxClick event is fired. But the CellValue of the checkbox is still the old value when checked in the CheckBox Event handler. Actually the CellValue is not changed until you click on another cell. How can I force the CellValue change to the new value without clicking on somewhere else?

Thanks
Dongxian

5 Replies

HA haneefm Syncfusion Team May 17, 2007 09:34 PM UTC

Hi Dongxian,

Regarding Question 1:
>>>>>>>>>>>>>>>>>>

You can try setting the SupportFocusControl property of the DropDownGridCellRenderer to true in DropDownGridCellRenderer constructor. Below is a code snippet

public class DropDownGridCellRenderer: GridDropDownGridCellRenderer
{
GridControlBase grid;

public DropDownGridCellRenderer(GridControlBase grid, GridCellModelBase cellModel)
: base(grid, cellModel)
{
this.SupportsFocusControl = true;
DropDownButton = new GridCellComboBoxButton(this);
this.grid = null;
}

//////////// YOUR CODE /////////////
}

Regarding Question 2:
>>>>>>>>>>>>>>>>>>

The reason is that you are not setting the checkboxoptions property in a cell. Here is a KB article that discuss with purpose of CheckBoxOptions in a grid's cell.
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=28

Best regards,
Haneef

Best regards,
Haneef


HA haneefm Syncfusion Team May 18, 2007 02:56 AM UTC

Hi Dongxian,

The CheckBoxClick is the event that gets triggered only when user clicks using the mouse on the checker box of checkbox. You can catch the CurrentCellChanged event for detecting any changes made to the checkbox cell.

void grid_CurrentCellChanged(object sender, EventArgs e)
{
GridCurrentCell cc = this.grid.CurrentCell;
if (cc.Renderer.StyleInfo.CellType == "CheckBox")
{
Console.WriteLine("CheckBox cell({0},{1})=> {2}", cc.RowIndex, cc.ColIndex, this.grid.Model[cc.RowIndex,cc.ColIndex].CellValue);
}
}

Best regards,
Haneef


HA haneefm Syncfusion Team May 18, 2007 02:57 AM UTC

Hi Dongxian,

The CheckBoxClick is the event that gets triggered only when user clicks using the mouse on the checker box of checkbox. You can catch the CurrentCellChanged event for detecting any changes made to the checkbox cell.

void grid_CurrentCellChanged(object sender, EventArgs e)
{
GridCurrentCell cc = this.grid.CurrentCell;
if (cc.Renderer.StyleInfo.CellType == "CheckBox")
{
Console.WriteLine("CheckBox cell({0},{1})=> {2}", cc.RowIndex, cc.ColIndex, this.grid.Model[cc.RowIndex,cc.ColIndex].CellValue);
}
}

Best regards,
Haneef


DL Dongxian Li May 18, 2007 05:43 AM UTC

Haneef,
Thank you.
That works.

Dongxian


DL Dongxian Li May 18, 2007 01:37 PM UTC

Hi Haneef,
Thank you for your support.
Your answer to question 1 solved my problem.
That is great. Thanks.

As for Question 2, I am actually using the example code that comes with the Syncfusion software (CellControlsGrid_2005.sln). The CheckBoxOption is set properly. When the checkbox is clicked, the cellValue toggles properly eventually. The only problem is that it returns the old cellValue in the CheckBoxClick event handler. Following is my code for getting the text:

private void gridControl1_CheckBoxClick(object sender, GridCellClickEventArgs e)
{

int row = e.RowIndex;
int col = e.ColIndex;

//the text returned is the old value before click. I hope to get the new value somewhere.
string text = gridControl1[row, col].Text;

}

You can use the example solution to reproduce the problem. My question is where can I get the new value after I clicked the checkbox but without clicking on anywhere else?

Thanks
Dongxian

Loader.
Live Chat Icon For mobile
Up arrow icon