Syncfusion.Grid.Windows
Example 


The GridCellButton to be drawn.
The System.Drawing.Graphics context of the canvas.
The System.Drawing.Rectangle with the bounds.
A System.Windows.Forms.ButtonState that specifies the current state.
The GridStyleInfo object that holds cell information.

OnDrawCellButtonBackground Method (GridCellRendererBase)

Syntax
'Declaration
 
Protected Overridable Sub OnDrawCellButtonBackground( _
   ByVal button As GridCellButton, _
   ByVal g As Graphics, _
   ByVal rect As Rectangle, _
   ByVal buttonState As ButtonState, _
   ByVal style As GridStyleInfo _
) 
'Usage
 
Dim instance As GridCellRendererBase
Dim button As GridCellButton
Dim g As Graphics
Dim rect As Rectangle
Dim buttonState As ButtonState
Dim style As GridStyleInfo
 
instance.OnDrawCellButtonBackground(button, g, rect, buttonState, style)
protected virtual void OnDrawCellButtonBackground( 
   GridCellButton button,
   Graphics g,
   Rectangle rect,
   ButtonState buttonState,
   GridStyleInfo style
)

Parameters

button
The GridCellButton to be drawn.
g
The System.Drawing.Graphics context of the canvas.
rect
The System.Drawing.Rectangle with the bounds.
buttonState
A System.Windows.Forms.ButtonState that specifies the current state.
style
The GridStyleInfo object that holds cell information.
Remarks
Override this method if you want to have buttons with a customized color, e.g. a push button drawn with the back color as specified with the interior property.
Example
This example draws a custom button element background.
public static void Draw3dFrame(Graphics g, int x0, int y0, int x1, int y1, int w, Color rgbTopLeft, Color rgbBottomRight)
{
    Rectangle rc;
            
    for (int i = 0; i != w; i++)
    {
        // Top
        Brush brTL = new SolidBrush(rgbTopLeft);
        rc = Rectangle.FromLTRB(x0, y0, x1, y0+1);
        g.FillRectangle(brTL, rc);
            
        // Left
        rc = Rectangle.FromLTRB(x0, y0, x0+1, y1);
        g.FillRectangle(brTL, rc);
        brTL.Dispose();
            
        Brush brBR = new SolidBrush(rgbBottomRight);
            
        // Bottom
        rc = Rectangle.FromLTRB(x0, y1, x1+1, y1+1);
        g.FillRectangle(brBR, rc);
            
        // Right
        rc = Rectangle.FromLTRB(x1, y0, x1+1, y1);
        g.FillRectangle(brBR, rc);
        brBR.Dispose();
            
        if (i != w-1)
        {
            x0++;
            y0++;
            x1--;
            y1--;
        }
    }
}
protected override void OnDrawCellButtonBackground(GridCellButton button, Graphics g, Rectangle rect, ButtonState buttonState, GridStyleInfo style)
{
    bool drawPressed = (buttonState & ButtonState.Pushed) != 0;
    Color hilight = SystemColors.ControlLightLight;
    Color shadow = SystemColors.ControlDarkDark;
    if (!drawPressed)
    {
        GridPaint.Draw3dFrame(g, rect.Left, rect.Top, rect.Right-1, rect.Bottom-1, 1,
            hilight, shadow);
    }
    else
    {
        Brush br = new SolidBrush(shadow);
        g.FillRectangle(br, Rectangle.FromLTRB(rect.Left, rect.Bottom-1, rect.Right-1, rect.Bottom));
        g.FillRectangle(br, Rectangle.FromLTRB(rect.Right-1, rect.Top, rect.Right, rect.Bottom));
        br.Dispose();
    }
}
Public Shared Sub Draw3dFrame(g As Graphics, x0 As Integer, y0 As Integer, x1 As Integer, y1 As Integer, w As Integer, rgbTopLeft As Color, rgbBottomRight As Color)
    Dim rc As Rectangle
            
    Dim i As Integer
            
    While i <> w
        ' Top
        Dim brTL = New SolidBrush(rgbTopLeft)
        rc = Rectangle.FromLTRB(x0, y0, x1, y0 + 1)
        g.FillRectangle(brTL, rc)
            
        ' Left
        rc = Rectangle.FromLTRB(x0, y0, x0 + 1, y1)
        g.FillRectangle(brTL, rc)
        brTL.Dispose()
            
        Dim brBR = New SolidBrush(rgbBottomRight)
            
        ' Bottom
        rc = Rectangle.FromLTRB(x0, y1, x1 + 1, y1 + 1)
        g.FillRectangle(brBR, rc)
            
        ' Right
        rc = Rectangle.FromLTRB(x1, y0, x1 + 1, y1)
        g.FillRectangle(brBR, rc)
        brBR.Dispose()
            
        If i <> w - 1 Then
            x0 += 1
            y0 += 1
            x1 -= 1
            y1 -= 1
        End If
        i += 1
    End While
End Sub 'Draw3dFrame
            
Protected Overrides Sub OnDrawCellButtonBackground(button As GridCellButton, g As Graphics, rect As Rectangle, buttonState As ButtonState, style As GridStyleInfo)
    Dim drawPressed As Boolean = (buttonState And ButtonState.Pushed) <> 0
    Dim hilight As Color = SystemColors.ControlLightLight
    Dim shadow As Color = SystemColors.ControlDarkDark
    If Not drawPressed Then
        GridPaint.Draw3dFrame(g, rect.Left, rect.Top, rect.Right - 1, rect.Bottom - 1, 1, hilight, shadow)
    Else
        Dim br = New SolidBrush(shadow)
        g.FillRectangle(br, Rectangle.FromLTRB(rect.Left, rect.Bottom - 1, rect.Right - 1, rect.Bottom))
        g.FillRectangle(br, Rectangle.FromLTRB(rect.Right - 1, rect.Top, rect.Right, rect.Bottom))
        br.Dispose()
    End If
End Sub 'OnDrawCellButtonBackground
AssemblyVersion

Syncfusion.Grid.Windows: 18.2460.0.44

See Also