[]
        
(Showing Draft Content)

C1.Win.SuperTooltip.C1SuperLabelBase.Measure

Measure Method

Measure()

Measures the width and height of the control content.

Declaration
public Size Measure()
Returns
Type Description
Size

Size object that represents the size of the content, in pixels.

Examples

The code below scans all the rows in a C1FlexGrid and calculates the width needed to display the cell with the widest content:

int GetMaximumCellWidth(int col)
{
  // maximum width is unknown
  int maxWidth = -1;

  // scan all rows to find the widest content
  for (int row = 0; row < _flex.Rows.Count; row++)
  {
    // get cell content
    string text = _flex.GetDataDisplay(row, col);

    // check that the cell contains html
    if (!string.IsNullOrEmpty(text) &&
         text.StartsWith("<html>"))
    {
      // measure width needed to render the Html
      _superLabel.Text = text;
      int width = _superLabel.Measure().Width;

      // save maximum width
      if (width > maxWidth)
        maxWidth = width;
  }
  return maxWidth;
}

Measure(Graphics)

Measures the width and height of the control content using specified Graphics.

Declaration
public Size Measure(Graphics graphics)
Parameters
Type Name Description
Graphics graphics

Graphics used to measure.

Returns
Type Description
Size

Size object that represents the size of the content, in pixels.

Measure(int)

Measures the height of the control content when rendered with a given width.

Declaration
public Size Measure(int width)
Parameters
Type Name Description
int width

Width used to calculate word-wrapping.

Returns
Type Description
Size

Size object that represents the size of the content, in pixels.

Examples

The code below scans all the columns in a C1FlexGrid and calculates the height needed to display the cell with the tallest content:

int GetMaximumCellHeight(int row)
{
  // maximum height is unknown
  int maxHeight = -1;

  // scan all columns to find the tallest content
  for (int col = 0; col < _flex.Cols.Count; col++)
  {
    // get cell content
    string text = _flex.GetDataDisplay(row, col);

    // check that the cell contains html
    if (!string.IsNullOrEmpty(text) &&
         text.StartsWith("<html>"))
    {
      // measure height needed to render the Html
      _superLabel.Text = text;
      int width = _flex.Cols[col].WidthDisplay;
      int height = _superLabel.Measure(width).Height;

      // save maximum height
      if (height > maxHeight)
        maxHeight = height;
  }
  return maxHeight;
}

Measure(Graphics, int)

Measures the height of the control content using specified Graphics when rendered with a given width.

Declaration
public Size Measure(Graphics graphics, int width)
Parameters
Type Name Description
Graphics graphics

Graphics used to measure.

int width

Width used to calculate word-wrapping.

Returns
Type Description
Size

Size object that represents the size of the content, in pixels.