[]
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:
Create a Windows Forms project and add C1ColorPicker control to the Form.
Add a RichTextBox control to the Form. Set the Text property of the RichTextBox to TextColor.
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.
Add the following code to the C1ColorPicker1_ValueChanged event handler to change the color of the text on color selection:
Private Sub C1ColorPicker1_ValueChanged(sender As Object, e As EventArgs) Handles C1ColorPicker1.ValueChanged
RichTextBox1.SelectionColor = DirectCast(DirectCast(sender, C1ColorPicker).Value, Color)
End Sub
private void c1ColorPicker1_ValueChanged(object sender, EventArgs e)
{
richTextBox1.SelectionColor = (Color)c1ColorPicker1.Value;
}
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.