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 Column Header of GGC

Thread ID:

Created:

Updated:

Platform:

Replies:

22944 Dec 30,2004 12:39 AM Mar 9,2005 01:59 PM Windows Forms 6
loading
Tags: Grouping
Lance
Asked On December 30, 2004 12:39 AM

How do I change a column header of GGC to be a checkbox that can listen to check/uncheck event?

Administrator [Syncfusion]
Replied On December 30, 2004 01:59 AM

You can use QueryCellStyleInfo to set the checkbox into a single header cell. You will need to have a varaible that maintains the value of this checkbox as well. You can set this in a TableControlCellClick event.
private bool col2Check = false;
private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
	if(e.TableCellIdentity.TableCellType == GridTableCellType.ColumnHeaderCell 
		&& e.TableCellIdentity.Column.Name == "Col2")
	{
		e.Style.CellType = "CheckBox";
		e.Style.Description = e.Style.Text;
		e.Style.CellValue = this.col2Check;
		e.Style.Enabled = true;
		//e.Style.BackColor = SystemColors.Window;
		//e.Style.CellAppearance = GridCellAppearance.Raised;
	}
}

private void gridGroupingControl1_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e)
{
	GridTableCellStyleInfo style = e.TableControl.Model[e.Inner.RowIndex, e.Inner.ColIndex];
	if(style.TableCellIdentity.TableCellType == GridTableCellType.ColumnHeaderCell 
		&& style.TableCellIdentity.Column.Name == "Col2")
	{
		this.col2Check = !this.col2Check;
		e.Inner.Cancel = true;
	}
}

Lance
Replied On December 30, 2004 05:53 AM

thanks! it worked well. didn''t know that i have to use code to set the check state of the checkbox. i was able to set the checkbox property from tabledescriptor->columns->[columnname]->appearance->columnheadercell

Shankar Ramasubramanian
Replied On March 8, 2005 03:49 PM

Clay, I have check boxes in the header cell of nested table. Then I need Col2Check variable to be a array of boolean values. My question to you is How do i get the row index of the parent table so i can store whether the check box is checked or not.

Administrator [Syncfusion]
Replied On March 8, 2005 06:52 PM

style.TableCellIdentity.ParentRecord will give you a reference to the parent record. You can then use this reference to get the row index in the parent table of a nested table. Example: Record r = style.TableCellIdentity.ParentRecord; int rowIndex = r.ParantTable.DisplayElements.IndexOf(r); Stefan >Clay, > I have check boxes in the header cell of nested table. Then I need Col2Check variable to be a array of boolean values. My question to you is How do i get the row index of the parent table so i can store whether the check box is checked or not.

Shankar Ramasubramanian
Replied On March 9, 2005 10:09 AM

stefan, I''m trying to get parent record in QueryCellStyleInfo event. ParentRecord is always nothing. Any suggestion. Thanks

Administrator [Syncfusion]
Replied On March 9, 2005 01:59 PM

Shankar, when the current context is that the element is a column header row of a nested table and you want to get the record that this nested table belongs to, you could do this: Element columnHeaderRow; ChildTable childTable = columnHeaderRow.ParentChildTable; NestedTable nestedTable = childTable.ParentNestedTable; Record parentRecord = nestedTable.ParentRecord; The key is to get first the ChildTable.ParentNestedTable and on that nested table call ParentRecord. Stefan >stefan, > I''m trying to get parent record in QueryCellStyleInfo event. ParentRecord is always nothing. Any suggestion. Thanks

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.

;