GrapeCity.Win.MultiRow Namespace > CellPaintingEventArgs Class : ClipBounds Property |
Public ReadOnly Property ClipBounds As Rectangle
Dim instance As CellPaintingEventArgs Dim value As Rectangle value = instance.ClipBounds
public Rectangle ClipBounds {get;}
The ClipBounds property represents the area of the Cell that needs to be repainted. For example, if a user covers the entire Cell with another window, and then uncovers it, then ClipBounds represents the entire Cell. If a user covers a small area of the Cell, and then uncovers it, then ClipBounds represents the small area that was covered.
The ClipBounds property may be a little bigger than CellBounds, because in GcMultiRow, the cell’s border may paint out of the cell’s area.
The zero point of the cell clip boundary is the owner section's top-left corner.
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
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