Control.GetStyle(ControlStyles) 方法

定義

擷取控制項指定控制項樣式位元的值。Retrieves the value of the specified control style bit for the control.

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 位元。The ControlStyles bit to return the value from.

傳回

如果指定的控制項樣式位元設定為 true,則為 true,否則為 falsetrue if the specified control style bit is set to true; otherwise, false.

範例

下列程式碼範例會傳回 Form 的雙緩衝相關樣式位的值。The following code example returns the value of the double-buffering related style bits for a Form. 只有在所有樣式位都設為 true 時,這個範例才會傳回 trueThis example returns true only if all the style bits are set to 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

備註

控制項樣式位旗標是用來分類支援的行為。Control style bit flags are used to categorize supported behavior. 控制項可以藉由呼叫 SetStyle 方法並傳入適當的 ControlStyles 位和布林值來啟用樣式,以將位設定為。A control can enable a style by calling the SetStyle method and passing in the appropriate ControlStyles bit and the Boolean value to set the bit to. 若要判斷指派給指定之 ControlStyles 位的值,請使用 GetStyle 方法,並傳入要評估的 ControlStyles 成員。To determine the value assigned to a specified ControlStyles bit, use the GetStyle method and pass in the ControlStyles member to evaluate.

適用於

另請參閱