Getting Started with WinForms Color Picker

18 Nov 20183 minutes to read

This section briefly describes how to create a new Windows Forms project in Visual Studio and add WinForms Color Picker with its basic functionalities.

Assembly deployment

Refer to the Control Dependencies section to get the list of assemblies or details of the 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 the WinForms Color Picker control via designer

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

  2. The WinForms Color Picker control can be added to an application by dragging it from the toolbox to the design view. The following dependent assemblies will be added automatically:

    • Syncfusion.Grid.Base
    • Syncfusion.Grid.Windows
    • Syncfusion.Shared.Base
    • Syncfusion.Shared.Windows
    • Syncfusion.Tools.Base
    • Syncfusion.Tools.Windows

WinForms Color Picker being dragged and dropped from the toolbox onto the form

Adding the WinForms Color Picker control via code

The control can be added programmatically by performing the following steps.

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

  2. Add the following assembly references to the project:

    • Syncfusion.Grid.Base
    • Syncfusion.Grid.Windows
    • Syncfusion.Shared.Base
    • Syncfusion.Shared.Windows
    • Syncfusion.Tools.Base
    • Syncfusion.Tools.Windows
  3. Include the required namespace Syncfusion.Windows.Forms.Tools.

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

    private Syncfusion.Windows.Forms.Tools.ColorPickerUIAdv colorPickerUIAdv1;
    this.colorPickerUIAdv1 = new ColorPickerUIAdv();
    this.colorPickerUIAdv1.Size = new Size(200, 180);
    this.Controls.Add(this.colorPickerUIAdv1);
    Private colorPickerUIAdv1 As Syncfusion.Windows.Forms.Tools.ColorPickerUIAdv
    Me.colorPickerUIAdv1 = New ColorPickerUIAdv()
    Me.colorPickerUIAdv1.Size = New Size(200, 180)
    Me.Controls.Add(Me.colorPickerUIAdv1)

WinForms Color Picker added to the form using code

Color selection

At runtime, a particular color can be focused or selected using the SelectedColor property.

this.colorPickerUIAdv1.SelectedColor = System.Drawing.Color.White;
Me.colorPickerUIAdv1.SelectedColor = System.Drawing.Color.White

WinForms Color Picker showing the selected color