GrapeCity MultiRow Windows Forms Documentation
CellPainting Event
Example 


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

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

PropertyDescription
CellBoundsGets the cell boundary.  
CellIndexGets the cell index in its parent Section.  
CellNameGets the name of the cell.  
CellStyleGets the display style of the Cell being painted.  
ClipBoundsGets the clip boundary of the current Cell that is being painted.  
EnabledGets a value that indicates whether this cell is enabled.  
ErrorIconGets the cell error icon.  
ErrorIconAlignmentGets the alignment of the error icon associated with the cell.  
ErrorTextGets the error text of the error that occurred on the cell.  
FormattedValueGets the formatted value of the current cell.  
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.  
SectionIndexGets the index of the owner Section that the event occurs for.  
SelectedGets a value that indicates whether the specified Cell is selected.  
ValueGets the cell value.  
ZoomFactorGets the zoom factor of the current GcMultiRow control.  
Remarks

You can handle this event to customize the cell appearance in the control. You can paint entire cells yourself, or paint specific parts of cells and use the CellPaintingEventArgs.PaintBackground, CellPaintingEventArgs.PaintForeground, CellPaintingEventArgs.PaintErrorIcon, or CellPaintingEventArgs.PaintBorder method to paint other parts.

When handling this event, you should access the cell with the event handler parameters, rather than accessing the cell 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 cells or sections paint logic.
void gcMultiRow_CellPainting(object sender, CellPaintingEventArgs e)
        {
            if (e.CellIndex == 1 && e.Scope == CellScope.Row)
            {
                e.PaintBackground(e.ClipBounds);

                PaintRateBlock(e);

                e.PaintForeground(e.ClipBounds);

                e.PaintBorder(e.ClipBounds);

                // If you customize the paint logic, make sure the Handled property is set to true.
                e.Handled = true;
            }
        }
Private Sub gcMultiRow_CellPainting(ByVal sender As Object, ByVal e As CellPaintingEventArgs) Handles 
gcMultiRow.CellPainting
        If e.CellIndex = 1 AndAlso e.Scope = CellScope.Row Then
            e.PaintBackground(e.ClipBounds)

            PaintRateBlock(e)

            e.PaintForeground(e.ClipBounds)

            e.PaintBorder(e.ClipBounds)

            ' 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.