【发布时间】:2014-05-04 09:50:21
【问题描述】:
这就是我想要执行的操作:
用户从背景颜色菜单中选择一种颜色。这会调出调色板,用户选择自定义 RGB 颜色,该颜色将是新的textboxMain.BackColor。
【问题讨论】:
这就是我想要执行的操作:
用户从背景颜色菜单中选择一种颜色。这会调出调色板,用户选择自定义 RGB 颜色,该颜色将是新的textboxMain.BackColor。
【问题讨论】:
来自微软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;
}
【讨论】: