[]
Draws the control content into a given Graphics object.
public void DrawToGraphics(Graphics g, Rectangle bounds)
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. |
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;
}
}
Draws an HTML string in the specified rectangle with the specified Brush and Font objects, starting at a given offset within the string.
public int DrawToGraphics(Graphics g, RectangleF bounds, int offset)
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). |
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. |