ComponentOne Input for WinForms
Using the C1Input Controls / C1Input Controls / C1ColorPicker Control Overview / Working with C1ColorPicker
In This Topic
    Working with C1ColorPicker
    In This Topic

    This topic illustrates how to use C1ColorPicker in Windows Forms applications. The steps to set up Visual Studio project and customize the application during runtime are as follows:

    1. Create a Windows Forms project and add C1ColorPicker control to the Form.
    2. Add a RichTextBox control to the Form. Set the Text property of the RichTextBox to TextColor. 
    3. Set the Color property of the C1ColorPicker control to a desired color from the palette. This enables the user to set a particular color as the current color instead of the default Transparent.
    4. Add the following code to the C1ColorPicker1_ValueChanged event handler to change the color of the text on color selection:
      Copy Code
      Private Sub C1ColorPicker1_ValueChanged(sender As Object, e As EventArgs) Handles C1ColorPicker1.ValueChanged
          RichTextBox1.SelectionColor = DirectCast(DirectCast(sender, C1ColorPicker).Value, Color)
      End Sub
      Copy Code
      private void c1ColorPicker1_ValueChanged(object sender, EventArgs e)
          richTextBox1.SelectionColor = (Color)c1ColorPicker1.Value;
    5. Run the application. Now you can select the color from the drop-down of the C1ColorPicker and set the color of the text in the RichTextBox control. The following image shows the output where the text is set as red.
    See Also