Checkbox in Column Header of GGC
How do I change a column header of GGC to be a checkbox that can listen to check/uncheck event?
SIGN IN To post a reply.
6 Replies
AD
Administrator
Syncfusion Team
December 30, 2004 06:59 AM UTC
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;
}
}
LA
Lance
December 30, 2004 10:53 AM UTC
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
SR
Shankar Ramasubramanian
March 8, 2005 08:49 PM UTC
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.
AD
Administrator
Syncfusion Team
March 8, 2005 11:52 PM UTC
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.
SR
Shankar Ramasubramanian
March 9, 2005 03:09 PM UTC
stefan,
I''m trying to get parent record in QueryCellStyleInfo event. ParentRecord is always nothing. Any suggestion. Thanks
AD
Administrator
Syncfusion Team
March 9, 2005 06:59 PM UTC
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
SIGN IN To post a reply.
- 6 Replies
- 3 Participants
-
LA Lance
- Dec 30, 2004 05:39 AM UTC
- Mar 9, 2005 06:59 PM UTC