如何使用颜色选择器调色板



这就是我想要执行的:用户从背景色菜单中选择一种颜色。这将调色板和用户选择一个自定义的RGB颜色,这个颜色将是新的textboxMain.BackColor

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;
}