Skip to main content

Apply Alpha Blending Using Appearances

  • 3 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.

Example

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.
vGridControl1.BeginUpdate();
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.
    vGridControl1.EndUpdate();
}