Question

So this is what I want to perform: User chooses a color from Background Color menu. This bring up the color pallete and user chooses a custom RGB color and this color will be the new textboxMain.BackColor.

Was it helpful?

Solution

From Microsoft ColorDialog Class:

private void button1_Click(object sender, System.EventArgs e)
{
    ColorDialog MyDialog = new ColorDialog();
    // Keeps the user from selecting a custom color.
    MyDialog.AllowFullOpen = false;
    // Allows the user to get help. (The default is false.)
    MyDialog.ShowHelp = true;
    // Sets the initial color select to the current text color.
    MyDialog.Color =  textboxMain.BackColor;

    // Update the text box color if the user clicks OK  
    if (MyDialog.ShowDialog() == DialogResult.OK)
         textboxMain.BackColor =  MyDialog.Color;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top