2.2.4.22.31 Grid::SetSelectionSetSelection
Description
SetSelection will be used to do multiple selection on a given Grid
Syntax
BOOL SetSelection( vector<int> & vR1, vector<int> & vC1 = NULL, vector<int> & vR2 = NULL, vector<int> & vC2 = NULL, BOOL bData = true )
Parameters
- vR1
- vector of indices of the first rows in the selection
- vC1
- [optional] vector of indices of the first columns in the selection
- vR2
- [optional] vector of indices of the last rows in the selection
- vC2
- [optional] vector of indices of the last columns in the selection
- bData
- decides whether the selection would be in data region or Labels region in worksheet
Return
True for success; otherwise false.
Examples
EX1
// example select all rows in a worksheet where
// col(1) is between 0.2 and 0.6
// To test, fill col(1) with uniform random numbers
//col(1)=uniform(1000)
void Grid_SetSelection_ex1(string strPre = "range a=1", string strCond = "a>=0.2 && a<=0.6")
{
Worksheet wks("Book1");
vector<uint> vnRowIndices;
int nn = wks.SelectRows(strCond, vnRowIndices, 0, -1, -1, strPre);
if(nn == 0)
out_str("no matching row");
else
{
Grid gg;
if(gg.Attach(wks))
{
vector<int> vnRows;
vnRows = vnRowIndices;
gg.SetSelection(vnRows);
out_int("Number of rows =", nn);
}
}
}
Remark
SetSelection will be used to do multiple selection on a given Grid. The optional args maybe skipped under the following three situations
SetSelection(vR1); // Full rows selected;
SetSelection(vR1, vC1);// individual cells selected
SetSelection(vR1, vC1, vR2, vC2);// partial cols selected;
See Also
Worksheet::SelectRows, Grid::GetSelection
Header to Include
origin.h
|