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


Glossary Item Box

Gets an ordered array of FarPoint.Win.Spread.Model.CellRange objects, from largest to smallest, containing the selected cells on the sheet with minimal overlap between the ranges.

Syntax

Visual Basic (Declaration) 
Public Function GetSelections() As CellRange()
Visual Basic (Usage)Copy Code
Dim instance As SheetView
Dim value() As CellRange
 
value = instance.GetSelections()
C# 
public CellRange[] GetSelections()

Return Value

Array of CellRange objects containing the selections

Remarks

This method is dependent on the selection model for the sheet (Models.Selection) implementing the IDisjointSelections interface. If this interface is not implemented on the selection model, then a single CellRange object is returned in the array for the current active cell.

Example

This example illustrates the use of this member by returning the first selection from the array of selections.
C#Copy Code
DialogResult dlg; 
fpSpread1.ActiveSheet.SelectionPolicy = FarPoint.Win.Spread.Model.SelectionPolicy.MultiRange;
fpSpread1.ActiveSheet.AddSelection(0, 0, 2, 2);
fpSpread1.ActiveSheet.AddSelection(0, 3, 2, 2);
dlg = MessageBox.Show("Do you want to get one of the selections?", "GetSelection", MessageBoxButtons.YesNo);
if (dlg == DialogResult.Yes)
{
    FarPoint.Win.Spread.Model.CellRange[] cr;
    cr = fpSpread1.ActiveSheet.GetSelections();
    label1.Text = "The selection covers cells " + cr[0].Row + ", " + cr[0].Column + ", " + cr[0].RowCount + ", " + cr[0].ColumnCount;
}
Visual BasicCopy Code
Dim dlg As DialogResult
FpSpread1.ActiveSheet.SelectionPolicy = FarPoint.Win.Spread.Model.SelectionPolicy.MultiRange
FpSpread1.ActiveSheet.AddSelection(0, 0, 2, 2)
FpSpread1.ActiveSheet.AddSelection(0, 3, 2, 2)
dlg = MessageBox.Show("Do you want to get one of the selections?", "GetSelection", MessageBoxButtons.YesNo)
If dlg = DialogResult.Yes Then
    Dim cr() As FarPoint.Win.Spread.Model.CellRange
    cr = FpSpread1.ActiveSheet.GetSelections()
    Label1.Text = "The  first selection covers cells " & cr(0).Row & ", " & cr(0).Column & ", " & cr(0).RowCount & ", " &
cr(0).ColumnCount
End If

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.