Getting Started with Windows Forms Gradient Panel

18 Nov 20185 minutes to read

This section will guide you to create a Gradient Panel via designer and also programming approach.

Assembly deployment

Refer to the Control Dependencies section to get the list of assemblies or details of NuGet package that needs to be added as a reference to use the control in any application.

Click NuGet Packages to learn how to install nuget packages in a Windows Forms application.

Adding Gradient Panel control via designer

  1. Create a new Windows Forms application in Visual Studio.

  2. The GradientPanel control can be added to an application by dragging it from the toolbox to a designer view. The following dependent assembly will be added automatically:

    • Syncfusion.Shared.Base

Windows Forms Gradient Panel drag and drop from toolbox

  1. Set background color to Gradient Panel through property grid.

Windows Forms Gradient Panel shows changing background style

Adding Gradient Panel control via code

The following steps guide you how to create a gradient panel programmatically.

  1. Create a C# or VB application via Visual Studio.

  2. Add the following assembly reference to the project:

    • Syncfusion.Shared.Base
  3. Include the required namespace.

    using Syncfusion.Windows.Forms.Tools;
    Imports Syncfusion.Windows.Forms.Tools
  4. Create an instance of GradientPanel control, and add it to the form.

    private Syncfusion.Windows.Forms.Tools.GradientPanel gradientPanel1;
    this.gradientPanel1 = new Syncfusion.Windows.Forms.Tools.GradientPanel();
    this.Controls.Add(this.gradientPanel1);
    Friend WithEvents GradientPanel1 As Syncfusion.Windows.Forms.Tools.GradientPanel
    Me.gradientPanel1 = New Syncfusion.Windows.Forms.Tools.GradientPanel()
    Me.Controls.Add(Me.gradientPanel1)

Styles

The Gradient Panel control provides different set of background styles. The styles are Solid, Pattern, and Gradient.

Solid

this.gradientPanel1.BackgroundColor = new Syncfusion.Drawing.BrushInfo(System.Drawing.Color.MediumBlue);
this.gradientPanel1.BorderColor = System.Drawing.Color.Red;
this.gradientPanel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
Me.gradientPanel1.BackgroundColor = New Syncfusion.Drawing.BrushInfo(System.Drawing.Color.MediumBlue)
Me.gradientPanel1.BorderColor = System.Drawing.Color.Red
Me.gradientPanel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

Windows Forms Gradient Panel shows solid style of background

Pattern

this.gradientPanel1.BackgroundColor = new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.PatternStyle.LargeCheckerBoard, System.Drawing.Color.Turquoise, System.Drawing.Color.MediumBlue);
this.gradientPanel1.BorderColor = System.Drawing.Color.PaleTurquoise;
this.gradientPanel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
Me.gradientPanel1.BackgroundColor = New Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.PatternStyle.LargeCheckerBoard, System.Drawing.Color.Turquoise, System.Drawing.Color.MediumBlue)
Me.gradientPanel1.BorderColor = System.Drawing.Color.PaleTurquoise
Me.gradientPanel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

Windows Forms Gradient Panel shows pattern style of background

Gradient

this.gradientPanel1.BackgroundColor = new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.ForwardDiagonal, System.Drawing.Color.Red, System.Drawing.Color.MediumBlue);
this.gradientPanel1.BorderColor = System.Drawing.Color.Transparent;
this.gradientPanel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
Me.gradientPanel1.BackgroundColor = New Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.ForwardDiagonal, System.Drawing.Color.Red, System.Drawing.Color.MediumBlue)
Me.gradientPanel1.BorderColor = System.Drawing.Color.Transparent
Me.gradientPanel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

Windows Forms Gradient Panel shows gradient style of background