TreeView for WinForms | ComponentOne
C1.Win.C1SuperTooltip Namespace / C1SuperLabelBase Class / DrawToGraphics Method / DrawToGraphics(Graphics,Rectangle) Method
System.Drawing.Graphics object where the content will be rendered.
System.Drawing.Rectangle that specifies the bounds where the content will be rendered.
Example

In This Topic
    DrawToGraphics(Graphics,Rectangle) Method
    In This Topic
    Draws the control content into a given System.Drawing.Graphics object.
    Syntax
    'Declaration
     
    
    Public Overloads Sub DrawToGraphics( _
       ByVal g As Graphics, _
       ByVal bounds As Rectangle _
    ) 
    public void DrawToGraphics( 
       Graphics g,
       Rectangle bounds
    )

    Parameters

    g
    System.Drawing.Graphics object where the content will be rendered.
    bounds
    System.Drawing.Rectangle that specifies the bounds where the content will be rendered.
    Example
    The example below uses the DrawToGraphics method to render Html in a C1FlexGrid control. Grid cells containing text that starts with an <html> tag are rendered as Html. Other cells are rendered by the grid as usual.
    void _flex_OwnerDrawCell(object sender, OwnerDrawCellEventArgs e)
    {
      // get cell content
      string text = _flex.GetDataDisplay(e.Row, e.Col);
                
      // check that the cell contains html
      if (!string.IsNullOrEmpty(text) &&
           text.StartsWith("<html>"))
      {
        // set label back color and content
        _superLabel.BackColor = e.Style.BackColor;
        _superLabel.Text = text;
                
        // draw the Html into grid cell
        _superLabel.DrawToGraphics(e.Graphics, e.Bounds);
                
        // cell has been drawn
        e.Handled = true;
      }
    }
    See Also