2.2.4.46.82 Worksheet::SetSelectedRange

Description

Highlight ranges as selected specified by input row and column indices

Syntax

BOOL SetSelectedRange( vector<int> & vR1, vector<int> & vC1 = NULL, vector<int> & vR2 = NULL, vector<int> & vC2 = NULL, BOOL bData = true )

Parameters

vR1
[input] vector of indices of the first rows in the selection
vC1
[input] vector of indices of the first columns in the selection
vR2
[input] vector of indices of the last rows in the selection,
if vR2[ii] = 1, means the iith subrange is from first row to last row.
vC2
[input] vector of indices of the last columns in the selection
bData
[input] decides whether the selection would be in data region(true by default) or Labels region in worksheet(false).

Return

TRUE for success, otherwise return 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 Worksheet_SetSelectedRange_Ex1(string strPre = "range a=1", string strCond = "a>=0.2 && a<=0.6")
{
    Worksheet wks = Project.ActiveLayer();
    if(!wks)
        return;
    
    vector<uint> vnRowIndices;
    vector<uint> vnCols = {0,2};
    int nn = wks.SelectRows(strCond, vnRowIndices, 0, -1, -1, strPre);
    if(nn == 0)
        out_str("no matching row");
    else
    {
        vector<int> vnRows;
        vnRows = vnRowIndices;
        wks.SetSelectedRange(vnRows);
        out_int("Number of rows =", nn);
    }
}

Remark

SetSelectedRange will be used to do multiple selection on a given Worksheet. The optional args maybe skipped under the following three situations

SetSelectedRange(vR1); // Full rows selected;

SetSelectedRange(vR1, vC1);// individual cells selected

SetSelectedRange(vR1, vC1, vR2);// partial cols selected;

See Also

Worksheet::SelectRows, Worksheet::GetSelectedRange

Header to Include

origin.h