Version

ShapeImage Property

Gets/sets the image used to generate the shape for the control.
Syntax
'Declaration
 
Public Property ShapeImage As Image
public Image ShapeImage {get; set;}
Remarks

The ShapeImage property is used to create a non-rectangular shaped button. The image specified for this property is used to create the region for the button control as well as being used to render the borders of the button. The color in the lower left hand pixel of the image is used to determine which color will be "masked" out - that is, which color will determine the areas of the image that are considered transparent. All pixels that do not match this color are considered to be opaque and will make up the displayed area of the button.

Example
The following sample demonstrates using the ShapeImage functionality of the UltraButton.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.Misc

Private Sub CreateShapeImage(ByVal button As Infragistics.Win.Misc.UltraButton)
    ' create a bitmap that will be used to provide the shape
    ' of the button.
    Dim bitmap As Bitmap = New Bitmap(100, 100)

    ' create a temporary graphics object so we can render into it
    Dim g As Graphics

    Try
        g = Graphics.FromImage(bitmap)

        ' draw the background in white. whatever color
        ' is in the lower left hand pixel will be assumed
        ' to be transparent
        g.Clear(Color.White)

        ' draw our circle in a different color
        g.DrawEllipse(Pens.Black, 0, 0, 99, 99)

        ' make sure to fill it in or the only displayed
        ' part of the button will be the outline of the
        ' circle
        g.FillEllipse(Brushes.Black, 0, 0, 99, 99)
    Finally
        g.Dispose()
    End Try

    ' set the shape
    button.ShapeImage = bitmap

    ' autosize to the shape image
    button.AutoSize = True
End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.Misc;

private void CreateShapeImage(Infragistics.Win.Misc.UltraButton button)
{
	// create a bitmap that will be used to provide the shape
	// of the button.
	Bitmap bitmap = new Bitmap(100,100);

	// create a temporary graphics object so we can render into it
	using (Graphics g = Graphics.FromImage(bitmap))
	{
		// draw the background in white. whatever color
		// is in the lower left hand pixel will be assumed
		// to be transparent
		g.Clear( Color.White );

		// draw our circle in a different color
		g.DrawEllipse( Pens.Black , 0, 0, 99, 99 );

		// make sure to fill it in or the only displayed
		// part of the button will be the outline of the
		// circle
		g.FillEllipse( Brushes.Black, 0, 0, 99, 99 );
	}

	// set the shape
	button.ShapeImage = bitmap;

	// autosize to the shape image
	button.AutoSize = true;
}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also