DrawToGraphics(Graphics,Rectangle) Method
Draws the control content into a given
System.Drawing.Graphics object.
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;
}
}