ColorDialog.AllowFullOpen 属性

获取或设置一个值,该值指示用户是否可以使用该对话框定义自定义颜色。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public Overridable Property AllowFullOpen As Boolean
用法
Dim instance As ColorDialog
Dim value As Boolean

value = instance.AllowFullOpen

instance.AllowFullOpen = value
public virtual bool AllowFullOpen { get; set; }
public:
virtual property bool AllowFullOpen {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_AllowFullOpen ()

/** @property */
public void set_AllowFullOpen (boolean value)
public function get AllowFullOpen () : boolean

public function set AllowFullOpen (value : boolean)

属性值

如果用户可定义自定义颜色,则为 true;否则为 false。默认为 true

备注

如果设置为 false,将禁用对话框中关联的按钮,而且用户无法访问对话框中的自定义颜色控件。

示例

下面的示例阐释如何创建新的 ColorDialog。此示例要求从一个现有窗体调用该方法,且该窗体上须有一个 TextBoxButton

Private Sub button1_Click(sender As Object, e As System.EventArgs)
    Dim MyDialog As 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 = textBox1.ForeColor

    ' Update the text box color if the user clicks OK 
    If (MyDialog.ShowDialog() = DialogResult.OK) Then
        textBox1.ForeColor =  MyDialog.Color
    End If

End Sub 'button1_Click
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 = textBox1.ForeColor ;
    
    // Update the text box color if the user clicks OK 
    if (MyDialog.ShowDialog() == DialogResult.OK)
        textBox1.ForeColor =  MyDialog.Color;
 }
    
private:
   void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      ColorDialog^ MyDialog = gcnew 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 = textBox1->ForeColor;
      
      // Update the text box color if the user clicks OK 
      if ( MyDialog->ShowDialog() == ::DialogResult::OK )
      {
         textBox1->ForeColor = MyDialog->Color;
      }
   }
protected void button1_Click(Object sender, System.EventArgs e)
{
    ColorDialog myDialog = new ColorDialog();
    // Keeps the user from selecting a custom color.
    myDialog.set_AllowFullOpen(false);
    // Allows the user to get help. (The default is false.)
    myDialog.set_ShowHelp(true);
    // Sets the initial color select to the current text color.
    myDialog.set_Color(textBox1.get_ForeColor());
    // Update the text box color if the user clicks OK 
    if (myDialog.ShowDialog().Equals(get_DialogResult().OK)) {
        textBox1.set_ForeColor(myDialog.get_Color());
    }
} //button1_Click

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

ColorDialog 类
ColorDialog 成员
System.Windows.Forms 命名空间
FullOpen