ControlStyles Énumération
Définition
Spécifie le style et le comportement d’un contrôle.Specifies the style and behavior of a control.
Cette énumération a un attribut FlagsAttribute qui permet une combinaison au niveau du bit de ses valeurs membres.
public enum class ControlStyles
[System.Flags]
public enum ControlStyles
type ControlStyles =
Public Enum ControlStyles
- Héritage
- Attributs
Champs
AllPaintingInWmPaint | 8192 | Si |
CacheText | 16384 | Si |
ContainerControl | 1 | Si |
DoubleBuffer | 65536 | Si |
EnableNotifyMessage | 32768 | Si |
FixedHeight | 64 | Si |
FixedWidth | 32 | Si |
Opaque | 4 | Si |
OptimizedDoubleBuffer | 131072 | Si |
ResizeRedraw | 16 | Si |
Selectable | 512 | Si |
StandardClick | 256 | Si |
StandardDoubleClick | 4096 | Si |
SupportsTransparentBackColor | 2048 | Si |
UserMouse | 1024 | Si |
UserPaint | 2 | Si |
UseTextForAccessibility | 262144 | Spécifie que la valeur de la propriété |
Exemples
L’exemple suivant montre une utilisation de ControlStyles avec la StyleChanged événement.The following example demonstrates a use of ControlStyles with the StyleChanged event.
private:
// Set the 'FixedHeight' and 'FixedWidth' styles to false.
void MyForm_Load( Object^ /*sender*/, EventArgs^ /*e*/ )
{
this->SetStyle( ControlStyles::FixedHeight, false );
this->SetStyle( ControlStyles::FixedWidth, false );
}
void RegisterEventHandler()
{
this->StyleChanged += gcnew EventHandler( this, &MyForm::MyForm_StyleChanged );
}
// Handle the 'StyleChanged' event for the 'Form'.
void MyForm_StyleChanged( Object^ /*sender*/, EventArgs^ /*e*/ )
{
MessageBox::Show( "The style releated to the 'Form' has been changed" );
}
// Set the 'FixedHeight' and 'FixedWidth' styles to false.
private void MyForm_Load(object sender, EventArgs e)
{
this.SetStyle(ControlStyles.FixedHeight, false);
this.SetStyle(ControlStyles.FixedWidth, false);
}
private void RegisterEventHandler()
{
this.StyleChanged += new EventHandler(MyForm_StyleChanged);
}
// Handle the 'StyleChanged' event for the 'Form'.
private void MyForm_StyleChanged(object sender, EventArgs e)
{
MessageBox.Show("The style releated to the 'Form' has been changed");
}
' Set the 'FixedHeight' and 'FixedWidth' styles to false.
Private Sub MyForm_Load(sender As Object, e As EventArgs)
Me.SetStyle(ControlStyles.FixedHeight, False)
Me.SetStyle(ControlStyles.FixedWidth, False)
End Sub
Private Sub RegisterEventHandler()
AddHandler Me.StyleChanged, AddressOf MyForm_StyleChanged
End Sub
' Handle the 'StyleChanged' event for the 'Form'.
Private Sub MyForm_StyleChanged(sender As Object, e As EventArgs)
MessageBox.Show("The style releated to the 'Form' has been changed")
End Sub
Remarques
Contrôles utilisent cette énumération dans diverses propriétés et méthodes pour spécifier des fonctionnalités.Controls use this enumeration in various properties and methods to specify functionality. Un contrôle peut activer un style en appelant le SetStyle (méthode) et en passant le texte approprié ControlStyles bits (ou bits) et la valeur booléenne à attribuer aux bits.A control can enable a style by calling the SetStyle method and passing in the appropriate ControlStyles bit (or bits) and the Boolean value to set the bit(s) to. Par exemple, la ligne de code Visual Basic suivante permettrait de double tampon.For example, the following line of Visual Basic code would enable double-buffering.
myControl.SetStyle(UserPaint Or AllPaintingInWmPaint Or DoubleBuffer, True)
Si le bit de AllPaintingInWmPaint est défini sur true
, le message de fenêtre WM_ERASEBKGND est ignoré, alors que les OnPaintBackground et OnPaint méthodes sont appelées directement à partir du message de fenêtre WM_PAINT.If the AllPaintingInWmPaint bit is set to true
, the window message WM_ERASEBKGND is ignored, and both OnPaintBackground and OnPaint methods are called directly from the window message WM_PAINT. Cela réduit généralement le scintillement, sauf si les autres contrôles envoient le message de fenêtre WM_ERASEBKGND au contrôle.This generally reduces flicker unless other controls send the window message WM_ERASEBKGND to the control. Vous pouvez envoyer le message de fenêtre WM_ERASEBKGRND pour obtenir un effet pseudo-aléatoire transparent similaire à SupportsTransparentBackColor ; par exemple, un ToolBar avec l’apparence à deux dimensions pour cela.You might send the window message WM_ERASEBKGRND to achieve a pseudo-transparent effect similar to SupportsTransparentBackColor; for example, a ToolBar with flat appearance does this.
Pour activer entièrement le mécanisme de double tampon, vous pouvez définir les bits OptimizedDoubleBuffer et AllPaintingInWmPaint sur true
.To fully enable double-buffering, you can set the OptimizedDoubleBuffer and AllPaintingInWmPaint bits to true
. Cependant la méthode recommandée pour la double mise en mémoire tampon, ce qui produit le même résultat, consiste à définir le DoubleBuffered propriété pour le contrôle à true
.However the preferred method for enabling double buffering, which yields the same result, is to set the DoubleBuffered property for the control to true
.
Si le bit SupportsTransparentBackColor est défini sur true
et le BackColor est définie sur une couleur dont le composant alpha est inférieur à 255, OnPaintBackground simule la transparence en demandant à son contrôle parent pour peindre l’arrière-plan.If the SupportsTransparentBackColor bit is set to true
, and the BackColor is set to a color whose alpha component is less than 255, OnPaintBackground will simulate transparency by asking its parent control to paint the background. Cela n’est pas une transparence true.This is not true transparency.
Notes
S’il existe un autre contrôle entre le contrôle et son parent, le contrôle en cours n’affichera pas le contrôle au milieu.If there is another control between the control and its parent, the current control will not show the control in the middle.
Quand le bit UserMouse est défini sur true
, les méthodes suivantes sont toujours appelées : Control.OnMouseDown, Control.OnMouseUp, Control.OnMouseEnter, Control.OnMouseMove, Control.OnMouseHover, Control.OnMouseLeave, et Control.OnMouseWheel.When the UserMouse bit is set to true
, the following methods are still called: Control.OnMouseDown, Control.OnMouseUp, Control.OnMouseEnter, Control.OnMouseMove, Control.OnMouseHover, Control.OnMouseLeave, and Control.OnMouseWheel.
Lorsque le contrôle est activé, si le bit StandardClick est défini sur true
le Control.OnClick méthode est appelée et déclenche le Control.Click événement.When the control is clicked, if the StandardClick bit is set to true
the Control.OnClick method is called and it raises the Control.Click event. Lorsqu’un double-clic est effectué sur le contrôle et le StandardClick et StandardDoubleClick bits sont définis sur true
, le clic est passé à la DoubleClick événement.When the control is double-clicked, and both the StandardClick and StandardDoubleClick bits are set to true
, the click is passed on to the DoubleClick event. Le Control.OnDoubleClick méthode est appelée et déclenche le Control.DoubleClick événement.Then the Control.OnDoubleClick method is called and it raises the Control.DoubleClick event. Toutefois, le contrôle peut appeler OnClick ou OnDoubleClick directement, quel que soit le StandardClick et StandardDoubleClick valeurs binaires.However, the control can call OnClick or OnDoubleClick directly regardless of the StandardClick and StandardDoubleClick bit values. Pour plus d’informations sur le contrôle cliquez sur et double-cliquez sur les comportements, consultez la Control.Click et Control.DoubleClick rubriques.For more information on control click and double click behaviors, see the Control.Click and Control.DoubleClick topics.
Lorsque le bit UseTextForAccessibility est défini et il existe une valeur dans le contrôle Text
propriété, la valeur de ce contrôle Text
propriété détermine touche par défaut Active Accessibility nom et le raccourci du contrôle.When the UseTextForAccessibility bit is set and there is a value in the control's Text
property, the value of that control's Text
property determines the control's default Active Accessibility name and shortcut key. Sinon, le texte de l’exemple précédent Label contrôle sera utilisé à la place.Otherwise, the text of the preceding Label control will be used instead. Ce style est défini par défaut.This style is set by default. Types de contrôle intégré, tels que TextBox et ComboBox, réinitialiser ce style afin que le Text
propriété de ces contrôles ne sera pas utilisée par Active Accessibility.Certain built-in control types, such as TextBox and ComboBox, reset this style so that the Text
property of those controls will not be used by Active Accessibility.