Control.GetStyle 方法
为控件检索指定控件样式位的值。
**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)
语法
声明
Protected Function GetStyle ( _
flag As ControlStyles _
) As Boolean
用法
Dim flag As ControlStyles
Dim returnValue As Boolean
returnValue = Me.GetStyle(flag)
protected bool GetStyle (
ControlStyles flag
)
protected:
bool GetStyle (
ControlStyles flag
)
protected boolean GetStyle (
ControlStyles flag
)
protected function GetStyle (
flag : ControlStyles
) : boolean
参数
- flag
从中返回值的 ControlStyles 位。
返回值
如果指定控件样式位设置为 true,则为 true;否则为 false。
备注
控件样式位标志用于对支持的行为进行分类。控件可以通过调用 SetStyle 方法并传入适当的 ControlStyles 位以及将该位设置成的 Boolean 值来启用样式。若要确定分配给指定的 ControlStyles 位的值,请使用 GetStyle 方法并传入要计算的 ControlStyles 成员。
示例
下面的代码示例为 Form 返回与双缓冲相关的样式位的值。此示例仅当所有样式位都设置为 true 时才返回 true。
Public Function DoubleBufferingEnabled() As Boolean
' Get the value of the double-buffering style bits.
Return Me.GetStyle((ControlStyles.DoubleBuffer _
Or ControlStyles.UserPaint _
Or ControlStyles.AllPaintingInWmPaint))
End Function
public bool DoubleBufferingEnabled()
{
// Get the value of the double-buffering style bits.
return this.GetStyle(ControlStyles.DoubleBuffer |
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint);
}
public:
bool DoubleBufferingEnabled()
{
// Get the value of the double-buffering style bits.
return this->GetStyle( static_cast<ControlStyles>(ControlStyles::DoubleBuffer | ControlStyles::UserPaint | ControlStyles::AllPaintingInWmPaint) );
}
public boolean DoubleBufferingEnabled()
{
// Get the value of the double-buffering style bits.
return this.GetStyle(ControlStyles.DoubleBuffer | ControlStyles.
UserPaint | ControlStyles.AllPaintingInWmPaint);
} //DoubleBufferingEnabled
平台
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
请参见
参考
Control 类
Control 成员
System.Windows.Forms 命名空间
SetStyle
ControlStyles