Spread Windows Forms 6.0 Product Documentation
PaintSelection Method
See Also  Example Support Options
FarPoint.Win.Spread Assembly > FarPoint.Win.Spread Namespace > GradientSelectionRenderer Class : PaintSelection Method


g
Graphics object used to paint the rectangle
x
X-coordinate of the upper-left corner of the rectangle to paint
y
Y-coordinate of the upper-left corner of the rectangle to paint
width
Width of rectangle to paint
height
Height of rectangle to paint

Glossary Item Box

Paints the selection.

Syntax

Visual Basic (Declaration) 
Public Sub PaintSelection( _
   ByVal g As Graphics, _
   ByVal x As Integer, _
   ByVal y As Integer, _
   ByVal width As Integer, _
   ByVal height As Integer _
) 
Visual Basic (Usage)Copy Code
Dim instance As GradientSelectionRenderer
Dim g As Graphics
Dim x As Integer
Dim y As Integer
Dim width As Integer
Dim height As Integer
 
instance.PaintSelection(g, x, y, width, height)
C# 
public void PaintSelection( 
   Graphics g,
   int x,
   int y,
   int width,
   int height
)

Parameters

g
Graphics object used to paint the rectangle
x
X-coordinate of the upper-left corner of the rectangle to paint
y
Y-coordinate of the upper-left corner of the rectangle to paint
width
Width of rectangle to paint
height
Height of rectangle to paint

Example

This example creates a custom selection renderer.
C#Copy Code
public class SelectionRenderer : FarPoint.Win.Spread.GradientSelectionRenderer {
    
    private Color clr1;
    
    private Color clr2;
    
    private System.Drawing.Drawing2D.LinearGradientMode gradMode;
    
    private int op;
    
    public SelectionRenderer(Color color1, Color color2, System.Drawing.Drawing2D.LinearGradientMode mode, int opacity) :

            base(Color.Beige, Color.Blue, Drawing2D.LinearGradientMode.ForwardDiagonal, 220) {
        clr1 = color1;
        clr2 = color2;
        gradMode = mode;
        op = opacity;
    }
    
    public new void PaintSelection(Graphics g, int x, int y, int width, int height) {
        if (((width > 0) 
                    && (height > 0))) {
            Color c1 = Color.FromArgb(op, clr1.R, clr1.G, clr1.B);
            Color c2 = Color.FromArgb(op, clr2.R, clr2.G, clr2.B);
            object selectionBrush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(x, y, width, height), c1,
c2, gradMode);
            g.FillRectangle(selectionBrush, x, y, width, height);
            selectionBrush.Dispose();
        }
    }
}
fpSpread1.SelectionRenderer = new SelectionRenderer(Color.Beige, Color.Blue, Drawing2D.LinearGradientMode.ForwardDiagonal,
220);
Visual BasicCopy Code
Public Class SelectionRenderer
Inherits FarPoint.Win.Spread.GradientSelectionRenderer

Private clr1 As Color
Private clr2 As Color
Private gradMode As System.Drawing.Drawing2D.LinearGradientMode
Private op As Integer

Public Sub New(ByVal color1 As Color, ByVal color2 As Color, ByVal mode As System.Drawing.Drawing2D.LinearGradientMode, ByVal
opacity As Integer)
MyBase.New(Color.Beige, Color.Blue, Drawing2D.LinearGradientMode.ForwardDiagonal, 220)
clr1 = color1
clr2 = color2
gradMode = mode
op = opacity
End Sub

Public Shadows Sub PaintSelection(ByVal g As Graphics, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal
height As Integer)
If width > 0 And height > 0 Then
Dim c1 As Color = Color.FromArgb(op, clr1.R, clr1.G, clr1.B)
Dim c2 As Color = Color.FromArgb(op, clr2.R, clr2.G, clr2.B)
Dim selectionBrush = New System.Drawing.Drawing2D.LinearGradientBrush(New Rectangle(x, y, width, height), c1, c2, gradMode)
g.FillRectangle(selectionBrush, x, y, width, height)
selectionBrush.Dispose()
End If
     End Sub
End Class

FpSpread1.SelectionRenderer = New SelectionRenderer(Color.Beige, Color.Blue, Drawing2D.LinearGradientMode.ForwardDiagonal,
220)

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

© 2002-2012 ComponentOne, a division of GrapeCity. All Rights Reserved.