Painting Column Captions
Hi,
I have a grid with 2 levels of hierarchy. In the lower most level I would like to paint one of the column captions with a string that is unique to that level of the hierarchy. The column in question, of course, was created and added to a header only once (but the column caption appears on the screen a few different times.
The following code actually works (draws) correctly but this is a hack and depends on the fact that the PaintColumnPanel event always proceeds the PaintColumnCaption events for the panel. Is the dependable? Can you think of a better solution?
public string lastText;
public static Font bnFont = new Font(FontFamily.GenericSansSerif.Name, 8.25F, FontStyle.Bold);
public void PaintColumnCaptionHandler(object sender, PaintColumnCaptionEventArgs e)
{
if (e.Column.Id == "Label")
{
e.Text = lastText;
e.Font = bnFont;
}
}
public void PaintColumnPanelHandler(object sender, PaintColumnPanelEventArgs e)
{
OrderGroupRow dRow = (OrderGroupRow)e.ParentRow.DataObject;
lastText = dRow.groupKey;
}
Regards,
-
Hello,
As we understand in the PaintColumnCaptionEventArgs event you do not have information on the row to which the header belongs. We will think about improving the API. Right now to get this row, you can use the following code:grid.PaintColumnCaption += delegate(object sender, PaintColumnCaptionEventArgs e)
{
if (e.Column.Id == "Label")
{
Row row = e.Grid.HitTests.RowTest(new Point(0, e.VirtualBounds.Bottom));
Row parentRow = row != null ? row.Parent : null;
//Do something...
//e.Text = lastText;
//e.Font = bnFont;
}
};Best regards,
The Dapfor Team0
Please sign in to leave a comment.
Comments
1 comment