Spread Windows Forms 7.0 Product Documentation
SelectionRenderer Property
See Also  Example Support Options
FarPoint.Win.Spread Assembly > FarPoint.Win.Spread Namespace > SpreadView Class : SelectionRenderer Property


Glossary Item Box

Gets or sets a renderer for drawing selections in the view.

Syntax

Visual Basic (Declaration) 
Public Property SelectionRenderer As ISelectionRenderer
Visual Basic (Usage)Copy Code
Dim instance As SpreadView
Dim value As ISelectionRenderer
 
instance.SelectionRenderer = value
 
value = instance.SelectionRenderer
C# 
public ISelectionRenderer SelectionRenderer {get; set;}

Property Value

ISelectionRenderer object that specifies the renderer

Example

This example sets the SelectionRenderer property.
C#Copy Code
public class CustomBorder : FarPoint.Win.Spread.ISelectionRenderer 
{ 
    public void PaintSelection(Graphics g, int x, int y, int width, int height) 
    { 
        if (width > 0 && height > 0) 
        { 
            int penWidthLeft = 2; 
            int penWidthRight = 5; 
            Pen selectionLeftPen = new Pen(Color.Red, penWidthLeft); 
            Pen selectionRightPen = new Pen(Color.Blue, penWidthRight); 
            int align = 0; 

            g.DrawLine(selectionLeftPen, x+penWidthLeft/2, y, x+penWidthLeft/2, y+height); 

            if (penWidthRight%2 > 0) 
                align = 1; 
            g.DrawLine(selectionRightPen, x+width-align-penWidthRight/2, y, x+width-align-penWidthRight/2, y+height); 
            selectionLeftPen.Dispose(); 
            selectionRightPen.Dispose(); 
        } 
    } 
} 

private void SetSelectionRenderer(object sender, System.EventArgs e)
{
    FarPoint.Win.Spread.SpreadView sv = fpSpread1.GetRootWorkbook();
    sv.SelectionRenderer = new CustomBorder();        
}
VB.NETCopy Code
Public Class CustomBorder
    Implements FarPoint.Win.Spread.ISelectionRenderer

    Public Sub PaintSelection(ByVal g As Graphics, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height
As Integer) Implements FarPoint.Win.Spread.ISelectionRenderer.PaintSelection
        If (width > 0 And height > 0) Then
            Dim penWidthLeft As Single = 2
            Dim penWidthRight As Single = 5
            Dim selectionLeftPen As New Pen(Color.Red, penWidthLeft)
            Dim selectionRightPen As New Pen(Color.Blue, penWidthRight)
            Dim align As Integer = 0

            g.DrawLine(selectionLeftPen, x + penWidthLeft / 2, y, x + penWidthLeft / 2, y + height)

            If (penWidthRight Mod 2 > 0) Then align = 1
            g.DrawLine(selectionRightPen, x + width - align - penWidthRight / 2, y, x + width - align - penWidthRight / 2,
y + height)
            selectionLeftPen.Dispose()
            selectionRightPen.Dispose()
        End If
    End Sub
End Class

Private Sub SetSelectionRenderer(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem78.Click
    Dim sv As FarPoint.Win.Spread.SpreadView = FpSpread1.GetRootWorkbook
    sv.SelectionRenderer = New CustomBorder()
    End Sub
End Class

Requirements

Target Platforms: Windows 2000 Professional (SP4), Windows 2000 Server, Windows 2003 Server (SP1), Windows 2008, Windows XP (SP2), Windows Vista, Windows 7, Windows 8

See Also

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