The Paint event is raised by each grid element after it has been painted in order to allow for additional custom painting of the grid element's foreground. To completely custom paint a grid element, jump to the Custom Painting topic.
Basic steps - C#
To subscribe to a Paint event, the following steps must be performed:
Private Sub group_MarginPaint( ByVal sender As Object, ByVal e As GridPaintEventArgs )
Dim margin As GroupMargin = CType( sender, GroupMargin ) Dim brush As New SolidBrush( Color.Black ) Dim starty As Integer = margin.ClientRectangle.Y
Dim row As Row For Each row In margin.ParentGroup.HeaderRows starty += row.Height Next row
If starty < margin.ClientRectangle.Bottom Then Dim font As New Font( margin.Font.FontFamily, 8, FontStyle.Bold ) Dim format As New StringFormat( StringFormatFlags.DirectionVertical )
e.Graphics.DrawString( margin.ParentGroup.Title, font, brush, margin.ClientRectangle.X,starty, format ) format.Dispose() font.Dispose() End If
brush.Dispose() End Sub
C#
Copy Code
Group group = new Group(); group.Margin.Paint += new GridPaintEventHandler( this.group_MarginPaint );