Hello,
I am using the GridDataBoundGrid control on a current project of mine. By default, the first column on the control (column 0) shows a little black triangle pointing to the row, when a row receives focus. I would like to change this.
Currently on my grid control, I have a ContextMenu on (column 0) for each row that is loaded. The ContextMenu is working just fine, however there is no indication to the user that is is there. I would like to put my own text on the row header (column 0) to let the user know they can click the row header to get more options, however all my attempts to do this are failing.
I have tried the following 2 events:
GridDataBoundGrid.PrepareViewStyleInfo() and GridDataBoundGrid.CellDrawn().
The following is the code:
private void gridVE_CellDrawn(object sender, GridDrawCellEventArgs e)
{
if (e.ColIndex == 0 && e.RowIndex != 0)
{
e.Style.Text = @"+ / -";
}
}
private void gridVE_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if (e.ColIndex == 0 && e.RowIndex != 0)
{
e.Style.Text = @"+ / -";
}
}
As I have stepped through the PrepareViewStyleInfo event, for some reason the Column Index never = 0, and so that method doesn't work.
As I have stepped through the CellDrawn event, the Column Index does hit 0, and the IF statement is entered, but the resulting grid control that is rendered does not show the text in the row headers.
Please advise as to what I am doing wrong.
Regards,
Pete
RC
Rajadurai C
Syncfusion Team
March 9, 2009 05:18 AM UTC
Hi Pete,
Thanks for your interest in Syncfusion products.
To set custom text in rowheader and remove the black triangle(current row indicator) in griddataboundgrid, please try to set the celltype of rowheader as "Header".
Please refer to the following code handled in PrepareViewStyleInfo event
this.gridDataBoundGrid1.PrepareViewStyleInfo += new Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventHandler(gridDataBoundGrid1_PrepareViewStyleInfo);
void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
if (e.RowIndex > 0 && e.ColIndex == 0)
{
e.Style.CellType = "Header";
e.Style.Text = "Click";
}
}
Regards,
Rajadurai
AD
Administrator
Syncfusion Team
March 9, 2009 02:04 PM UTC
Thank you!
if (e.RowIndex > 0 && e.ColIndex == 0)
{
e.Style.CellType = "Header";
e.Style.Text = "Click";
}
Above code was the piece I was missing.
RC
Rajadurai C
Syncfusion Team
March 10, 2009 05:29 AM UTC
Hi Pete,
Thanks for your update.
Regards,
Rajadurai