| 2.2.4.5.41 Column::SetAsCategoricalSetAsCategorical
 DescriptionSet the column as categorical.
 Syntaxint SetAsCategorical( int nType, BOOL bUndo = FALSE, BOOL bShowReminder = FALSE ) Parameters nType[input] categorical map type, can beCMT_NONE,
Remove the categorical settings, won't set the column as categorical
CMT_NOMINAL,
Set the column as categorical.  It is similar to clear the <auto> check box on the Categories dialog. Work together with CategoricalMap::ReplaceMap to specify a customized categorical map.
CMT_ORDINAL
Set the column as Categorial. It is similar to select <auto> check box on the Categories dialog. Work together with CategoricalMap::ArrangeAZ and CategoricalMap::ArrangeZA to sort the categories list as descending or ascending order.
  bUndo [input] whether the action should be undoable.  bShowReminder [input] show reminder message box when set as categorical
 Returnreturn TRUE for success, FALSE for failure.
 Examplesvoid Column_SetAsCategorical_ex1()
{
	Dataset ds1;
	Worksheet wks = Project.ActiveLayer();
	ds1.Attach(wks,0); 
	vector<int> vi = {1, 2, 10, 21};
	ds1 = vi;
    
    if ( wks )
    {
        //set the first column in worksheet as categorical
        Column col(wks, 0);
        int nType = CMT_NOMINAL; //set as CMT_ORDINAL, when sort ascending, data like "1, 2, 10, 21" will be sorted as "1, 10, 2, 21";
                                 //if set as CMT_NOMINAL, "1, 2, 10, 21" will be sorted as "1, 2, 10, 21"; if set as CMT_NONE, it won't set the column as categorical
        int nRet = col.SetAsCategorical(nType);
        wks.Sort(0,SORT_ASCENDING);
        if ( nRet )
            out_str("Column set as categorical.");
    }
}RemarkSee AlsoColumn::GetCategoricalMap
 Header to Includedorigin.h
 |