GrapeCity MultiRow Windows Forms Documentation
SectionPainting Event
Example 


Occurs when a section needs to be drawn.
Syntax
<SRDescriptionAttribute("Occurs when a section needs to be drawn.")>
<SRCategoryAttribute("Display")>
Public Event SectionPainting As EventHandler(Of SectionPaintingEventArgs)
Dim instance As GcMultiRow
Dim handler As EventHandler(Of SectionPaintingEventArgs)
 
AddHandler instance.SectionPainting, handler
[SRDescription("Occurs when a section needs to be drawn.")]
[SRCategory("Display")]
public event EventHandler<SectionPaintingEventArgs> SectionPainting
Event Data

The event handler receives an argument of type SectionPaintingEventArgs containing data related to this event. The following SectionPaintingEventArgs properties provide information specific to this event.

PropertyDescription
ClipBoundsGets the clip area of the current Section that is being painted.  
GraphicsGets the graphics object used to draw the cell.  
Handled (Inherited from System.ComponentModel.HandledEventArgs)
IsPrintingGets a value that indicates whether this cell is being printed.  
RowIndexGets the index of the owner Row that the event occurs for.  
ScopeGets the cell area that the event occurs for.  
SectionBoundsGets the boundary of this section.  
SectionIndexGets the index of the owner Section that the event occurs for.  
ZoomFactorGets the zoom factor of the current GcMultiRow control.  
Remarks

You can handle this event to customize the appearance of sections in the control. You can paint entire sections yourself, or paint specific parts of sections and use the SectionPaintingEventArgs.PaintSectionBackground, SectionPaintingEventArgs.PaintCells, or SectionPaintingEventArgs.PaintSectionBorder method to paint other parts.

When handling this event, you should access the section through the event handler parameters, rather than accessing the section directly.

The paint result can output a PrintStyle.Rich style print, but cannot output a PrintStyle.Compact style print.

Example
The following code example shows how to customize the sections paint logic. This code example is part of a larger example provided for the CellPainting event.
void gcMultiRow_SectionPainting(object sender, SectionPaintingEventArgs e)
        {
            if (e.RowIndex == this.gcMultiRow.NewRowIndex && e.Scope == CellScope.Row)
            {
                e.Paint(e.ClipBounds);

                StringFormat sf = new StringFormat();
                sf.Alignment = StringAlignment.Center;

                // Paint string in section face.
                e.Graphics.DrawString("Edit cell in this row to add new rows", gcMultiRow.Font, Brushes.Gray, 
e.SectionBounds, sf);

                // If you customize the paint logic, make sure the Handled property is set to true.
                e.Handled = true;
            }
        }
Private Sub gcMultiRow_SectionPainting(ByVal sender As Object, ByVal e As SectionPaintingEventArgs) Handles 
gcMultiRow.SectionPainting
        If e.RowIndex = Me.gcMultiRow.NewRowIndex AndAlso e.Scope = CellScope.Row Then
            e.Paint(e.ClipBounds)

            Dim sf As New StringFormat()
            sf.Alignment = StringAlignment.Center

            ' Paint string in section face.
            e.Graphics.DrawString("Edit cell in this row to add new rows", gcMultiRow.Font, Brushes.Gray, 
e.SectionBounds, sf)

            ' If you customize the paint logic, make sure the Handled property is set to true.
            e.Handled = True
        End If
    End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

GcMultiRow Class
GcMultiRow Members

 

 


Copyright © GrapeCity, inc. All rights reserved.