本文整理汇总了C#中System.Windows.Forms.ColorDialog.SolidColorOnly属性的典型用法代码示例。如果您正苦于以下问题:C# ColorDialog.SolidColorOnly属性的具体用法?C# ColorDialog.SolidColorOnly怎么用?C# ColorDialog.SolidColorOnly使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Windows.Forms.ColorDialog
的用法示例。
在下文中一共展示了ColorDialog.SolidColorOnly属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeColorDialog
// This method initializes ColorDialog1 to allow any colors,
// and combination colors on systems with 256 colors or less,
// but will not allow the user to set custom colors. The
// dialog will contain the help button.
private void InitializeColorDialog()
{
this.ColorDialog1 = new System.Windows.Forms.ColorDialog();
this.ColorDialog1.AllowFullOpen = false;
this.ColorDialog1.AnyColor = true;
this.ColorDialog1.SolidColorOnly = false;
this.ColorDialog1.ShowHelp = true;
// Associate the event-handling method with
// the HelpRequest event.
this.ColorDialog1.HelpRequest
+= new System.EventHandler(ColorDialog1_HelpRequest);
}
// This method opens the dialog and checks the DialogResult value.
// If the result is OK, the text box's background color will be changed
// to the user-selected color.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
DialogResult result = ColorDialog1.ShowDialog();
if (result.Equals(DialogResult.OK))
{
TextBox1.BackColor = ColorDialog1.Color;
}
}
// This method is called when the HelpRequest event is raised,
//which occurs when the user clicks the Help button on the ColorDialog object.
private void ColorDialog1_HelpRequest(object sender, System.EventArgs e)
{
MessageBox.Show("Please select a color by clicking it. "
+ "This will change the BackColor property of the TextBox.");
}