本文整理匯總了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);
}
}
}