Skip to main content

Implement Alpha Blending Using Appearances

  • 4 minutes to read

The alpha blending feature enables you to enhance the appearance of a grid control by painting its elements using transparent brushes and pens. This topic explains how to implement the alpha blending feature by customizing the appearance settings used to paint the grid elements.

Appearances and Alpha Blending

The GridControl provides advanced appearance technology that can be used to customize the appearance of the following.

  • View elements of a particular type. For instance, you can change the appearance of column headers, indicator cells, preview sections, etc.
  • Cells in an individual column. See the Appearance and Conditional Formatting topic for additional information.
  • Individual cells. The ways in which this can be done are described in the Appearance and Conditional Formatting topic.

Appearances are represented by the AppearanceObject objects that provide a number of properties that affect the appearance of View elements. When implementing alpha blending, only properties that specify the background and foreground colors are used (the AppearanceObject.BackColor, AppearanceObject.BackColor2 and AppearanceObject.ForeColor properties). The first two properties specify the starting and ending colors of the gradient that fills an element’s background. The AppearanceObject.ForeColor property specifies the color of the text.

Note that there are two possible situations when setting an element’s background.


Specific view elements do not allow you to change their background in specific paint themes. For instance, the background of the Group Panel cannot be modified when any skin or the Office2003 paint theme is applied.

Example of Implementing Alpha Blending Using Appearances

This example shows how to set the transparency of GridControl‘s empty space and the group panels at design time. As a result, the grid’s background image will be partially visible.

Follow the steps below.

  1. Select the grid control to display its properties within the Properties window and assign an image to its BackgroundImage property.
  2. Invoke the Grid Designer and switch to the Appearances page. Set the Paint Style setting to Flat.

    Implement Alpha Blending Using Appearances-SetFlatPaintStyle

  3. Select the Empty appearance and set its background color to Transparent, as shown in the image below. This will make the grid’s background image visible in the View area that is not occupied by any elements.

    Implement Alpha Blending Using Appearances-Empty

  4. Select the GroupPanel appearance and change its background color value to (100, 22, 69, 145).

    Implement Alpha Blending Using Appearances-GroupPanel

  5. Run the application.

    Implement Alpha Blending Using Appearances-Result  

All of the above can also be performed via code as shown in the sample code below. The code is enclosed in calls to the BaseView.BeginUpdate and BaseView.EndUpdate methods, to prevent the control from being updated multiple times.

// Lock the control to prevent it from being repainted.
try {
   // Specify the grid's background image.
   gridControl1.BackgroundImage = Image.FromFile("c:\\Images\\gridBgImage.jpg");
   // Enable the Flat paint style.
   gridView1.PaintStyleName = "Flat";
   // Modify the appearance settings used to paint an Empty space.
   gridView1.Appearance.Empty.BackColor = Color.Transparent;
   // Modify the group panel's appearance settings.
   gridView1.Appearance.GroupPanel.BackColor = Color.FromArgb(100, 22, 69, 145);
finally {
   // Unlock the control and repaints it based on the changes made.

The Appearances page of the Grid Designer provides you with design-time facilities not only for modifying the appearance layouts, but also to save or load them. At runtime, the appearance layout can be saved and then restored using the methods provided by the BaseAppearanceCollection class. This allows the appearance settings to be saved to the system registry, a stream or an XML file. For general information on appearances, see the Appearance and Conditional Formatting document.

See Also