Provides data and methods to paint Grid background

Namespace: Dapfor.Net.Ui
Assembly: Dapfor.Net (in Dapfor.Net.dll) Version: 2.10.3.24917 (2.10.3.24917)

Syntax

C#
public sealed class PaintBackgroundEventArgs : EventArgs
Visual Basic
Public NotInheritable Class PaintBackgroundEventArgs
	Inherits EventArgs
Visual C++
public ref class PaintBackgroundEventArgs sealed : public EventArgs
F#
[<SealedAttribute>]
type PaintBackgroundEventArgs =  
    class
        inherit EventArgs
    end

Remarks

.Net Grid provides broad functionality of displaying various grid elements, such as cells, rows, headers and columns.

There two ways for grid customization:

Generally paint arguments contain the following information:

  • Full and clipped sizes of the painted element
  • Graphics object
  • Colors and parameters used for elemebt painting (they can be altered)
  • Methods for painting every single part of an element (for a Cell there are methods for painting background, text, selection, focus etc.)
  • Painting filter PaintPart, which allows to skip a certain part of an element (partial painting)
  • PaintAll() method that paints all elements defined in the PaintPart filter
  • Handled property that forbids a grid to perform default painting

Note that the whole painting process is accumulated in paint arguments object and consists of the following: a grid creates PaintXXXEventArgs object, sets default parameters, fires Grid.PaintXXX event, and if Handled property is set to false, invokes PaintAll() method. This mechanism is used to paint all elements of the .Net Grid cells, rows, columns, headers, hierarchy tree etc.

We have intentionally described the process of painting in details to show broad and rich abilities of grid customization. In other words, you may customize any parameters, some painted elements (cell, column) and even use Graphics object to manipulate the grid. Even better, this approach enables you to define a painting sequence. For example, you may perform some default actions and then finish drawing with the Graphics object, or do it vice versa!

The following example shows how to draw text over Grid

 Copy imageCopy
public void InitializeGrid(Grid grid)
{
    //Add an event handler 
    grid.PaintBackground += delegate(object sender, PaintBackgroundEventArgs e)
    {
        //Do default painting 
        e.PaintAll();
        e.Handled = true;

        //Draw a string in middle of row
        using (Font font = new Font("Arial", 20, FontStyle.Bold | FontStyle.Italic))
        using (StringFormat sf = new StringFormat())
        {
            sf.LineAlignment = StringAlignment.Center;
            sf.Alignment = StringAlignment.Center;
            e.Graphics.DrawString("Dapfor .Net Grid", font, SystemBrushes.GrayText, grid.ClientRectangle, sf);
        }
    };
}

Inheritance Hierarchy

System..::..Object
  System..::..EventArgs
    Dapfor.Net.Ui..::..PaintBackgroundEventArgs

See Also