[]
        
(Showing Draft Content)

C1.Win.SuperTooltip.C1SuperLabelBase.DrawToGraphics

DrawToGraphics Method

DrawToGraphics(Graphics, Rectangle)

Draws the control content into a given Graphics object.

Declaration
public void DrawToGraphics(Graphics g, Rectangle bounds)
Parameters
Type Name Description
Graphics g

Graphics object where the content will be rendered.

Rectangle bounds

Rectangle that specifies the bounds where the content will be rendered.

Examples

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;
  }
}

DrawToGraphics(Graphics, RectangleF, int)

Draws an HTML string in the specified rectangle with the specified Brush and Font objects, starting at a given offset within the string.

Declaration
public int DrawToGraphics(Graphics g, RectangleF bounds, int offset)
Parameters
Type Name Description
Graphics g

Graphics object where the content will be rendered.

RectangleF bounds

Rectangle that specifies the bounds where the content will be rendered.

int offset

Offset of the first line to draw (usually the return value of a previous call to DrawStringHtml).

Returns
Type Description
int

The offset of the first line that was not printed because it did not fit in the specified rectangle, or the value of MaxValue if the entire string was rendered. By default zero.