Spread Windows Forms 9.0 Product Documentation
SelectionRenderer Property (SpreadView)
Example 


Gets or sets a renderer for drawing selections in the view.
Syntax
'Declaration
 
Public Property SelectionRenderer As ISelectionRenderer
'Usage
 
Dim instance As SpreadView
Dim value As ISelectionRenderer
 
instance.SelectionRenderer = value
 
value = instance.SelectionRenderer
public ISelectionRenderer SelectionRenderer {get; set;}

Property Value

ISelectionRenderer object that specifies the renderer
Example
This example sets the SelectionRenderer property.
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();        
}
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 Server 2012 R2, Windows 2008, Windows XP (SP2), Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10

See Also

Reference

SpreadView Class
SpreadView Members

User-Task Documentation

Customizing the Selection Indicator

 

 


Copyright © GrapeCity, inc. All rights reserved.