Syncfusion.Grid.Windows
Example 


The System.Drawing.Graphics context of the canvas.
The target area the grid should be drawn to.

DrawClippedGrid(Graphics,Rectangle) Method

Draws the portion of the grid within the clipBounds to the specified System.Drawing.Graphics canvas. Clipping will automatically occur when the grid was horizontally scrolled and the first column is only partially or when the grid was vertically scrolled and the first row is only partially visible.
Syntax
'Declaration
 
Public Overloads Sub DrawClippedGrid( _
   ByVal g As Graphics, _
   ByVal clipBounds As Rectangle _
) 
'Usage
 
Dim instance As GridControlBase
Dim g As Graphics
Dim clipBounds As Rectangle
 
instance.DrawClippedGrid(g, clipBounds)
public void DrawClippedGrid( 
   Graphics g,
   Rectangle clipBounds
)

Parameters

g
The System.Drawing.Graphics context of the canvas.
clipBounds
The target area the grid should be drawn to.
Remarks
Use this method if you want to increase performance when you have frequent Invalidate(Rectangle) and Update() calls.
Example
This sample below lets you draw changes cells directly to graphics context instead of using the conventional Invalidate / Update approach.
bool drawDirectToDC = true;
Graphics g = null;
            
if (drawDirectToDC)
    g = m_syncGrid.CreateGridGraphics();
            
// Clear our volatile cache
m_syncGrid.ResetVolatileData();
            
// Handle case when values is change for current cell.
if (g1 == m_syncGrid.CurrentCell.RangeInfo)
{
    m_syncGrid.CurrentCell.Model.ResetActiveText(row, col);
    continue;
}
            
// Draw direct to dc
if (drawDirectToDC)
{
    Rectangle bounds = m_syncGrid.RangeInfoToRectangle(g1);
    if (!bounds.IsEmpty)
    {
    // Instead of
    if (false)
    {
            // Draw each cell individually to graphics context
            
        GridStyleInfo style = this.m_syncGrid.Model[row, col];
        GridCellRendererBase renderer = this.m_syncGrid.CellRenderers[style.CellType];
            
        // Get client rectangle
        bounds = style.CellModel.SubtractBorders(bounds, style, this.m_syncGrid.IsRightToLeft());
            
        // Draw cell Background
        Syncfusion.Drawing.BrushPaint.FillRectangle(g, bounds, style.Interior);
            
        // Draw cell text
        renderer.Draw(g, bounds, row, col, style);
    }
    else
    {
        // DrawClippedGrid method lets you simply draw the cells at the specified bounds directly to the graphics context.
        // less code than drawing each cell individually ....
            
        m_syncGrid.DrawClippedGrid(g, bounds);
    }
}
else
{
    // Use more conventional Invalidate / Update mechanism.
        m_syncGrid.RefreshRange(GridRangeInfo.Cell(row, col);
}
            
if (g != null)
    g.Dispose();
AssemblyVersion

Syncfusion.Grid.Windows: 17.3460.0.14

See Also