Grouping is a common feature found in most of the grids. To apply grouping in C1TrueDBGrid all we need to do is set the DataView property of C1TrueDBGrid to GroupBy. Please refer to the following link to know more about it. https://www.grapecity.com/componentone/docs/win/online-truedbgrid/overview.html When grouping is performed, row selection in C1TrueDBGrid behaves in the following manner :
In this blog, we'll discuss how to customize this default behavior in the following ways:
To accomplish this, we need to set the FetchStyle property of all the columns in the grid to True, so as to raise the FetchGroupCellStyle event . Later, the same event is used to highlight the group header row depending on whether it is the selected row or not.
this.c1TrueDBGrid1.FetchGroupCellStyle += (s1, e1) =>
{
var grid = s1 as C1.Win.C1TrueDBGrid.C1TrueDBGrid;
if (e1.Row == 0 & start)
{
e1.CellStyle.BackColor = Color.Transparent;
e1.CellStyle.ForeColor = Color.Black;
start = false;
}
else
{
if (e1.Row == row)
{
if (grid.Splits[0].Rows[e1.Row].RowType == C1.Win.C1TrueDBGrid.RowTypeEnum.ExpandedGroupRow| grid.Splits[0].Rows[e1.Row].RowType == C1.Win.C1TrueDBGrid.RowTypeEnum.CollapsedGroupRow)
{
e1.CellStyle.BackColor = Color.Blue;
e1.CellStyle.ForeColor = Color.White;
}
}
else
{
e1.CellStyle.BackColor = Color.Transparent;
e1.CellStyle.ForeColor = Color.Black;
}
}
};
Download the following samples for complete implementation. Download Sample - VB Download Sample - C#