<< Return to Main Index

< Return to Class Index

CGXGridCore::GetColWidth

virtual int GetColWidth(ROWCOL nCol);

nCol

Specifies the column id.

Return Value

Returns the column-width in pixels. If it is 0, the column is hidden.

Remarks

Overridable method which returns the column-width in pixels.

Note that this value is computed from an internally stored logical width that considers the font-size of the standard-style and the zooming-factor.

Width_LPtoDP helps you convert from logical to pixel values when you override this method. You should also consider calling IsColHidden to ensure that you return 0 for hidden columns.

Note

The base-class version of this method will limit the cell size so that it is not larger than the grid width. If you want cells that are larger than the grid, you should set the attribute m_bLimitColWidth = FALSE.

Example

This example illustrates overriding GetColWidth.

int CDBaseBrowserView::GetColWidth(ROWCOL nCol)
{
   ASSERT(nCol <= INT_MAX);

   if (nCol > 0)
   {
      // GX_NXAVGWIDTH is average logical width of a char
      // Width_LPtoDP converts from logical to pixel value
      if (IsColHidden(nCol))
         return 0;
      else
         return Width_LPtoDP( GetField(nCol)->width * GX_NXAVGWIDTH);
   }

   return CGXGridView::GetColWidth(nCol);
}

See Also

CGXGridCore::SetColWidth CGXGridCore::IsColHidden CGXGridCore::Width_LPtoDP

CGXGridCore

Class Overview | Class Members