TreeView for WinForms | ComponentOne
C1.Win.C1SuperTooltip Namespace / C1SuperLabelBase Class / Measure Method / Measure() Method
Example

In This Topic
    Measure() Method
    In This Topic
    Measures the width and height of the control content.
    Syntax
    'Declaration
     
    
    Public Overloads Function Measure() As Size
    public Size Measure()

    Return Value

    System.Drawing.Size object that represents the size of the content, in pixels.
    Example
    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;
    }
    See Also