CheckedListBox.CreateParams 属性

定义

获取创建控件句柄时所需要的创建参数。

protected:
 virtual property System::Windows::Forms::CreateParams ^ CreateParams { System::Windows::Forms::CreateParams ^ get(); };
protected override System.Windows.Forms.CreateParams CreateParams { get; }
member this.CreateParams : System.Windows.Forms.CreateParams
Protected Overrides ReadOnly Property CreateParams As CreateParams

属性值

CreateParams

包含所需参数的 CreateParams

示例

下面的代码示例扩展 CreateParams 派生类的属性 Button 。 属性 CreateParams.Style 已更改,这会导致按钮显示 Icon 而不是 Image显示 。 此示例要求你有一个从类继承的 Button 类。

virtual System::Windows::Forms::CreateParams^ get() override
{
   
   // Extend the CreateParams property of the Button class.
   System::Windows::Forms::CreateParams^ cp = __super::CreateParams;

   // Update the button Style.
   cp->Style |= 0x00000040; // BS_ICON value
   return cp;
}
protected override CreateParams CreateParams
{
    get
    {
        // Extend the CreateParams property of the Button class.
        CreateParams cp = base.CreateParams;
        // Update the button Style.
        cp.Style |= 0x00000040; // BS_ICON value

        return cp;
    }
}

Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
    Get
        Dim SecPerm As New SecurityPermission(SecurityPermissionFlag.UnmanagedCode)
        SecPerm.Demand()

        ' Extend the CreateParams property of the Button class.
        Dim cp As System.Windows.Forms.CreateParams = MyBase.CreateParams
        ' Update the button Style.
        cp.Style = cp.Style Or &H40 ' BS_ICON value

        Return cp
    End Get
End Property

注解

不应重写该 CreateParams 属性,并用于调整派生控件的属性。 属性(如 CreateParams.Caption,)应CreateParams.Height由控件中的相应属性设置,例如Control.TextControl.Width以及Control.HeightCreateParams.WidthCreateParams仅当包装标准Windows控件类或设置Windows 窗体命名空间未提供的样式时,才应扩展该样式。 有关创建控件参数的详细信息,请参阅CreateWindowWindows 平台 SDK参考中的/CreateWindowEx函数和CREATESTRUCT结构文档。

继承者说明

重写 CreateParams 派生类中的属性时,请使用基类的属性 CreateParams 扩展基实现。 否则,必须提供所有实现。

适用于