Skip to main content

Apply Alpha Blending Using Appearances

  • 4 minutes to read

The Alpha Blending feature allows you to enhance the appearance of a vertical 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 vertical grid elements.

Appearances and Alpha Blending

The vertical grid controls (VGridControl and PropertyGridControl) allow you to customize the appearance of the following.

Appearances are represented by AppearanceObject objects, which provide a number of properties that affect the appearance of grid elements. When alpha blending is implemented, only the properties that specify the background colors and gradient mode are used (the AppearanceObject.BackColor, AppearanceObject.BackColor2 and AppearanceObject.GradientMode properties). The BackColor and BackColor2 properties specify the starting and ending colors of the gradient that fills the element’s background. The GradientMode property specifies the gradient direction.

There are two possible situations when setting an element’s background:


This example shows how to set the transparency for row headers and empty space within a VGridControl. As a result, the vertical grid’s background image will be partially visible.

Follow the steps below.

  1. Select the control to display its properties within the Properties window and assign an image to its BackgroundImage property.

    AlphaBlending - Styles - AssignImage

  2. Invoke the VerticalGrid Designer and switch to the Appearances page.
  3. Select the Empty appearance in the Appearances list and set its BackColor property to Transparent. This will make the vertical grid’s background image visible in the control area that is not occupied by any elements.

    AlphaBlending - Styles - TransparentEmpty

  4. Select the RowHeaderPanel item in the Appearances list (this appearance item corresponds to non-focused row headers) and set its background color to a semi-transparent color: (150, 209, 157, 139).

    AlphaBlending - Styles - TransparentHeaders

  5. Select the FocusedRow item in the Appearances list (this appearance item corresponds to the focused row header) and set its background color to another semi-transparent color: (150, 255, 177, 179).

    AlphaBlending - Styles - TransparentFocusedRowHeaders

  6. Run the application. The image below shows the result.

    AlphaBlending - Styles - Result


Runtime Example

All of the above can also be done via code, as shown in the sample code below. The code is enclosed in calls to the VGridControlBase.BeginUpdate and VGridControlBase.EndUpdate methods to prevent the vertical grid from being updated numerous times.

// Lock the control to prevent it from being repainted multiple times.
try {
    // Specify the vertical grid's background image.
    vGridControl1.BackgroundImage = Image.FromFile("c:\\Images\\bg6.png");
    // Modify the appearance settings used to paint the Empty region.
    vGridControl1.Appearance.Empty.BackColor = Color.Transparent;
    // Modify the appearance settings of row headers.
    vGridControl1.Appearance.RowHeaderPanel.BackColor = Color.FromArgb(150, 209, 157, 139);
    vGridControl1.Appearance.FocusedRow.BackColor = Color.FromArgb(150, 255, 177, 179);
finally {
    // Unlock the control and repaint it with respect to the changes made.