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

Checkbox in hierarchical Grid

Hi, i got a problem setting checkbox values in a nested childtable according to another value. I''m using the TableControlCheckBoxClick event to catch clicks on the Checkboxes. I have a nested table with a checkbox column and a text column. I want to change the value of the text column when the checkbox gets checked or unchecked. It works after 2 clicks on the checkbox but gets out of sync again when i click into another checkbox in that row. Here the corresponding text value for the old checkbox gets changed but not the one for the new checkbox. Can you tell how i can overcome this problem ?? Thanks I''m using the following code: private void m_syncGrid_TableControlCheckBoxClick(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellClickEventArgs e) { if (e.TableControl.CurrentCell.Renderer == null) return; Console.WriteLine("col: " + e.Inner.ColIndex.ToString() + ", row: " + e.Inner.RowIndex.ToString()); GridTableCellStyleInfoIdentity tableCellInfo = e.TableControl.CurrentCell.Renderer.StyleInfo.CellIdentity as GridTableCellStyleInfoIdentity; GridRecord rec = (tableCellInfo.DisplayElement as GridRecordRow).ParentRecord; bool bTest = Convert.ToBoolean( rec.GetValue(Proposal.Constants.DataBase.col_VarVariantenmarker_Custom) ); //bool bTest = Convert.ToBoolean(e.TableControl.CurrentCell.Renderer.ControlValue); Console.WriteLine(" Fired : " + bTest); if (bTest) { rec.SetValue(Proposal.Constants.DataBase.col_VarMarkerManuell, 1); rec.SetValue(Proposal.Constants.DataBase.col_VarMarker, 1); } else { rec.SetValue(Proposal.Constants.DataBase.col_VarMarkerManuell, 0); rec.SetValue(Proposal.Constants.DataBase.col_VarMarker, 0); } }

5 Replies

AD Administrator Syncfusion Team April 11, 2005 09:40 AM UTC

Before ddoing the code that changes the text based on the checkbox, make sure the click is in the proper checkbox column. You can do this by testing the value of tableCellInfo.Column.MappingName. this should tell you the checkbox column that was clicked.


AD Administrator Syncfusion Team April 11, 2005 12:38 PM UTC

I didn''t mean to switch the column, this problem also occurs if I switch the rows. Somehow the old checkbox keeps its focus a little longer than it should. So if the event fires still the old cell is selected and not the newly clicked one.


AD Administrator Syncfusion Team April 11, 2005 12:46 PM UTC

see the sample attached. If you click a Checkbox in the nested table the value in Col3 int the same row should change it''s value. If you click on the checkbox below the old value in Col3 is changed and the new checkbox. What is wrong ? Thanks, oliver GGC_BookMark_9162.zip


AD Administrator Syncfusion Team April 11, 2005 07:22 PM UTC

The first time you click on a bool cell, there may not be an active cell renderer at this point. This means your code in teh checkboxclick event is being skipped as you are checking the renderere at the beginning. Try this code.
private void gridGroupingControl1_TableControlCheckBoxClick(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellClickEventArgs e)
{
	GridTableCellStyleInfoIdentity tableCellInfo = e.TableControl.Model[e.Inner.RowIndex, e.Inner.ColIndex].CellIdentity as GridTableCellStyleInfoIdentity;
	GridRecord rec = (tableCellInfo.DisplayElement as GridRecordRow).ParentRecord;
	object o = rec.GetValue("boolCol");
	bool bTest = (o == DBNull.Value) ? false : (bool)o;

	Console.WriteLine("		Fired : " + bTest + "   " + rec.GetValue("Col3").ToString());

	if (bTest)
	{
		rec.SetValue("Col3", 1);
	}
	else
	{
		rec.SetValue("Col3", 0);
	}
	rec.EndEdit();
}


AD Administrator Syncfusion Team April 12, 2005 07:31 AM UTC

prefect, that works... Thank you once more ;)

Loader.
Live Chat Icon For mobile
Up arrow icon