Control.GetStyle(ControlStyles) 方法

定義

擷取控制項指定控制項樣式位元的值。

protected:
 bool GetStyle(System::Windows::Forms::ControlStyles flag);
protected bool GetStyle (System.Windows.Forms.ControlStyles flag);
member this.GetStyle : System.Windows.Forms.ControlStyles -> bool
Protected Function GetStyle (flag As ControlStyles) As Boolean

參數

flag
ControlStyles

要傳回值的來源 ControlStyles 位元。

傳回

Boolean

如果指定的控制項樣式位元設定為 true,則為 true,否則為 false

範例

下列程式碼範例會傳回 的雙緩衝相關樣式位 Form 值。 只有當所有樣式位都設定 true 為 時,這個範例才會傳回 true

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 bool DoubleBufferingEnabled()
{
   // Get the value of the double-buffering style bits.
   return this.GetStyle(ControlStyles.DoubleBuffer | 
      ControlStyles.UserPaint | 
      ControlStyles.AllPaintingInWmPaint);
}
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

備註

控制項樣式位旗標可用來分類支援的行為。 控制項可以藉由呼叫 SetStyle 方法並傳入適當的 ControlStyles 位和布林值來設定位來啟用樣式。 若要判斷指派給指定 ControlStyles 位的值,請使用 GetStyle 方法並傳入 ControlStyles 成員來評估。

適用於

另請參閱