GrapeCity.Win.MultiRow Namespace : CellPaintingEventArgs Class |
Public Class CellPaintingEventArgs Inherits System.ComponentModel.HandledEventArgs
Dim instance As CellPaintingEventArgs
public class CellPaintingEventArgs : System.ComponentModel.HandledEventArgs
The GcMultiRow.CellPainting event is raised for each Cell that is visible on a GcMultiRow control. To improve performance, set the properties in a CellStyle to change the appearance of the cell instead of directly accessing a cell in the GcMultiRow control. If you manually paint the cell, set the System.ComponentModel.HandledEventArgs.Handled property to true. If you do not set System.ComponentModel.HandledEventArgs.Handled to true, the cell will paint over your customizations.
In GcMultiRow's painting logic, a cell's paint work can be divided in five areas. There are cell backgrounds, cell foregrounds, cell borders, cell error icons, and cell wave lines. Different cell types may have different definitions about what is the cell's foreground or background. You can refer to individual cell types for detailed information.
There are five methods: PaintForeground, PaintBackground, PaintBorder, PaintErrorIcon, and PaintWaveLine. Each one corresponds to a painting area of a cell. If you do not want to manually paint all parts of a cell, you can call these methods to help paint. The default order when painting a cell is background->foreground->error icon->wave line->cell border.
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 static void PaintRateBlock(CellPaintingEventArgs e) { Color color1 = Color.Red; Color color2 = Color.Orange; if (e.Selected) { color1 = Color.Blue; color2 = Color.SkyBlue; } decimal rate = 0m; if (e.Value != null) { rate = (decimal)(e.Value) / 100m; } // Calculate block size. int spinButtonWidth = 17; int blockWidth = (int)((e.ClipBounds.Width - spinButtonWidth) * rate); if (blockWidth > 0) { Rectangle rect = e.CellBounds; rect.Width = blockWidth; LinearGradientBrush brush = new LinearGradientBrush(rect, color1, color2, LinearGradientMode.Vertical); e.Graphics.FillRectangle(brush, rect); } }
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 Private Shared Sub PaintRateBlock(ByVal e As CellPaintingEventArgs) Dim color1 As Color = Color.Red Dim color2 As Color = Color.Orange If e.Selected Then color1 = Color.Blue color2 = Color.SkyBlue End If Dim rate As Decimal = 0D If e.Value <> Nothing Then rate = DirectCast((e.Value), Decimal) / 100D End If ' Calculate block size. Dim spinButtonWidth As Integer = 17 Dim blockWidth As Integer = CInt((e.ClipBounds.Width - spinButtonWidth) * rate) If blockWidth > 0 Then Dim rect As Rectangle = e.CellBounds rect.Width = blockWidth Dim brush As New LinearGradientBrush(rect, color1, color2, LinearGradientMode.Vertical) e.Graphics.FillRectangle(brush, rect) End If End Sub
System.Object
System.EventArgs
System.ComponentModel.HandledEventArgs
GrapeCity.Win.MultiRow.CellPaintingEventArgs
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