Control.GetStyle(ControlStyles) Control.GetStyle(ControlStyles) Control.GetStyle(ControlStyles) Control.GetStyle(ControlStyles) Method

定義

擷取控制項指定控制項樣式位元的值。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 ControlStyles 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.

範例

下列程式碼範例會傳回雙重緩衝的樣式相關值的位元的FormThe 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.

適用於

另請參閱