2.2.4.5.58 Column::SetSubFormat

Description

Set the SubFormat used by a column.

Syntax

BOOL SetSubFormat( int iSubFormat, int iFormatToUse = -1 )

Parameters

iSubFormat
[input] The integer (enumerated from zero) of the subformat for the current column type.
iFormatToUse
[input] The integer (enumerated from zero) of the column type to use, -1 means current column type.

Return

TRUE if set the column subformat successfully, otherwise FALSE.

An error occurs when a subformat is out of range. For example, any value for a Text column or a value greater than 21 for a Date column.

Examples

EX1

// Get the active worksheet, set column Format as DATE and set it's SubFormats
void    Column_SetSubFormat_Ex1()
{
    Worksheet wks = Project.ActiveLayer();

    if (!wks)
    	return;
    
    Column colA(wks, 0);
    
    colA.SetFormat(OKCOLTYPE_DATE);     // Column Format is DATE
    colA.SetSubFormat(13);              // The 14th SubFormat (value = 13) of DATE is yyMMdd HH:mm:ss
}

EX2

// Get the active worksheet, set column Format as NUMERIC and set it's SubFormats
void    Column_SetSubFormat_Ex2()
{
    Worksheet wks = Project.ActiveLayer();
	
    if (!wks)
    	return;
    
    Column colB(wks, 1);
    
    colB.SetFormat(OKCOLTYPE_NUMERIC);  // Column Format is NUMERIC
    colB.SetSubFormat(3);               // The 4th SubFormat (value = 3) of NUMERIC is Decimal: 1,000
}

Remark

Each Format have some SubFormat, you can choose different Format in the Worksheet Column Properties dialog and see the SubFormat corresponding to that Format at the 'Display' label. The GetSubFormat and SetSubFormat function will return or use the index of the combo box in the label to represent different SubFormat.

See Also

Column::GetSubFormat

Header to Include

origin.h