<< Return to Main Index

< Return to Class Index

CGXWrappedGrid::ResizeWGColWidthsToFit

virtual BOOL ResizeWGColWidthsToFit(CGXRange& range, UINT nFlags = GX_UPDATENOW);

range

Specifies the range of cells through which ResizeWGColWidthsToFit will loop to find the optimal width for the affected columns.

nFlags

Specifies the update technique:

GX_UPDATENOW specifies to update the window after each column-width change.

GX

INVALIDATE simply invalidates the window area to the right of the first column that is resized.

GX_NOSHRINKSIZE specifies that the column-width should not become smaller. Columns shall only be enlarged.

Return Value

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

Remarks

Call this command to automatically resize the column-widths for a given range of logical cells.

ResizeWGColWidthsToFit will loop through each logical cell in the range and call the associated control’s CalcSize method to determine the optimal width for the cell. For each logical column, ResizeWGColWidthsToFit calculates the maximal width from the individual logical cells.

The user can abort the operation.

All SetWGColWidth commands are packed in a transaction (BeginTrans, CommitTrans block). Therefore, the user can undo all changes with one undo-command.

Example

The first example resizes logical columns 2 to 5:

ResizeWGColWidthsToFit(CGXRange().SetCols(2,5));

The next example resizes the column of the current cell.

ROWCOL nAbsRow, nAbsCol;
if(GetCurrentCell(nAbsRow, nAbsCol))
{
   ROWCOL nLogRow, nLogCol;
   GetLogCellFromAbsCell(nAbsRow, nAbsCol, nLogRow, nLogCol);
   if(nLogCol != GX_INVALID)
      ResizeWGColWidthsToFit(CGXRange(nLogRow, nLogCol));
}

See Also

CGXWrappedGrid::SetWGColWidth CGXWrappedGrid::ResizeWGRowHeightsToFit

CGXWrappedGrid

Class Overview | Class Members