本文整理汇总了C#中System.Windows.Forms.ColorDialog.AnyColor属性的典型用法代码示例。如果您正苦于以下问题:C# ColorDialog.AnyColor属性的具体用法?C# ColorDialog.AnyColor怎么用?C# ColorDialog.AnyColor使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Windows.Forms.ColorDialog
的用法示例。
在下文中一共展示了ColorDialog.AnyColor属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.");
}
示例2: Main
//引入命名空间
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
public class Test
{
static void Main()
{
System.Windows.Forms.ColorDialog colorDlg = new System.Windows.Forms.ColorDialog();
colorDlg.AnyColor = true;
colorDlg.ShowHelp = true;
if (colorDlg.ShowDialog() != DialogResult.Cancel)
{
string strARGB = colorDlg.Color.ToString();
Console.WriteLine(strARGB);
}
}
}