<< Return to Main Index

< Return to Class Index

CGXGridCore::SetColCount

virtual BOOL SetColCount(ROWCOL nCols, UINT flags = GX_UPDATENOW);

nCols

Specifies the new number of columns.

flags

Specifies the update technique. This parameter is passed either to InsertCols or RemoveCols.

Return Value

TRUE if the command was successful; FALSE if it failed.

Remarks

Inserts or removes columns by calling either InsertCols or RemoveCols.

You can override this method and call StoreColCount to change the data and update the display with UpdateChangedColCount (both methods are undocumented, but will remain in the library). In earlier versions, this technique was used to change the number of columns. A disadvantage of this technique was missing support for undo and redo and code redundancy. For this reason, the method passes the responsibility to InsertCols or RemoveCols.

SetColCount must not be called before the grid has been initialized with OnGridInitialUpdate or Initialize.

Example

The first example illustrates how to set the number rows and columns in a grid control.

CGXGridWnd* pGridWnd = new CGXGridWnd( );
VERIFY(pGridWnd->Create(WS_VSCROLL | WS_HSCROLL, rect, this, ID_GRID));
pGridWnd->Initialize( );
pGridWnd->SetRowCount(32);
pGridWnd->SetColCount(16);

The second example illustrates how to set the number rows and columns in a grid view.

void CGridSampleView::OnInitialUpdate( )
{
   ...

   CGXGridView::OnInitialUpdate( );

   SetRowCount(512);
   SetColCount(28);

   ...
}

See Also

CGXGridCore::InsertCols CGXGridCore::RemoveCols CGXGridCore::ClearCells

CGXGridCore

Class Overview | Class Members