Spread ASP.NET 6.0 Product Documentation
SetSelection Method
See Also  Example Send Feedback
FarPoint.Web.Spread Assembly > FarPoint.Web.Spread.Model Namespace > DefaultSheetSelectionModel Class : SetSelection Method


row
Row index of the first cell
column
Column index of the first cell
rowCount
Number of rows to add to the first cell to define the selection
columnCount
Number of columns to add to the first cell to define the selection

Glossary Item Box

Selects the cells in the specified range.

Syntax

Visual Basic (Declaration) 
Public Overrides Sub SetSelection( _
   ByVal row As Integer, _
   ByVal column As Integer, _
   ByVal rowCount As Integer, _
   ByVal columnCount As Integer _
) 
Visual Basic (Usage)Copy Code
Dim instance As DefaultSheetSelectionModel
Dim row As Integer
Dim column As Integer
Dim rowCount As Integer
Dim columnCount As Integer
 
instance.SetSelection(row, column, rowCount, columnCount)
C# 
public override void SetSelection( 
   int row,
   int column,
   int rowCount,
   int columnCount
)

Parameters

row
Row index of the first cell
column
Column index of the first cell
rowCount
Number of rows to add to the first cell to define the selection
columnCount
Number of columns to add to the first cell to define the selection

Remarks

Use this method to specify the anchor (first cell in a selection) and the number of rows and columns to include in the selection. Between (and including) the anchor and the extent is the selection or selected range of cells.

Example

This example assigns a DefaultSheetSelectionModel to the default SelectionModel of the spreadsheet. A selection is added to object, and then several of the methods and properties are set and the values returned to a list box. The selection can be cleared in a button click event.
C#Copy Code
  private void Page_Load(object sender, System.EventArgs e)
  {
     if (this.IsPostBack) return;

   FpSpread1.ActiveSheetView.ColumnCount = 8;
   FpSpread1.ActiveSheetView.RowCount = 10;
   FpSpread1.ActiveSheetView.SelectionBackColor = Color.Yellow;
   FarPoint.Web.Spread.Model.ISheetSelectionModel model = FpSpread1.ActiveSheetView.SelectionModel;
   
   bool b1, b2, b3;
   int i1;
   model.AddSelection(0, 0, 3, 3);
   b1 = model.IsAnyCellInColumnSelected(2);
   b2 = model.IsAnyCellInRowSelected(2);
   b3 = model.IsSelected(1,1);
   i1 = model.Count;
   ListBox1.Items.Add(Convert.ToString(b1));
   ListBox1.Items.Add(Convert.ToString(b2));
   ListBox1.Items.Add(Convert.ToString(b3));
   ListBox1.Items.Add(Convert.ToString(i1));
  }

  private void Button1_Click(object sender, System.EventArgs e)
  {
   FarPoint.Web.Spread.Model.ISheetSelectionModel model = FpSpread1.Sheets[0].SelectionModel;
   model.ClearSelection();
  }
Visual BasicCopy Code
  Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
     If (IsPostBack) Then Return

     Dim b1, b2, b3 As Boolean
     Dim i1 As Integer
     FpSpread1.ActiveSheetView.ColumnCount = 8
     FpSpread1.ActiveSheetView.RowCount = 10
     FpSpread1.ActiveSheetView.SelectionBackColor = Color.Yellow
     Dim model As FarPoint.Web.Spread.Model.ISheetSelectionModel = FpSpread1.Sheets(0).SelectionModel
     model.AddSelection(0, 0, 3, 3)
     b1 = model.IsAnyCellInColumnSelected(2)
     b2 = model.IsAnyCellInRowSelected(2)
     b3 = model.IsSelected(1,1)
     i1 = model.Count
     ListBox1.Items.Add(b1)
     ListBox1.Items.Add(b2)
     ListBox1.Items.Add(b3)
     ListBox1.Items.Add(i1)

  End Sub

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
     Dim model As FarPoint.Web.Spread.Model.ISheetSelectionModel = FpSpread1.Sheets(0).SelectionModel
     model.ClearSelection()
  End Sub

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2002-2012 GrapeCity, Inc. All Rights Reserved.