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.

Checkbox in hierarchical Grid

Thread ID:

Created:

Updated:

Platform:

Replies:

27337 Apr 11,2005 05:17 AM Apr 12,2005 03:31 AM Windows Forms 5
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On April 11, 2005 05:17 AM

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); } }

Administrator [Syncfusion]
Replied On April 11, 2005 05:40 AM

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.

Administrator [Syncfusion]
Replied On April 11, 2005 08:38 AM

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.

Administrator [Syncfusion]
Replied On April 11, 2005 08:46 AM

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

Administrator [Syncfusion]
Replied On April 11, 2005 03:22 PM

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();
}

Administrator [Syncfusion]
Replied On April 12, 2005 03:31 AM

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

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.

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.

;