Control.SelectNextControl(Control, Boolean, Boolean, Boolean, Boolean) Méthode
Définition
Active le contrôle suivant.Activates the next control.
public:
bool SelectNextControl(System::Windows::Forms::Control ^ ctl, bool forward, bool tabStopOnly, bool nested, bool wrap);
public bool SelectNextControl (System.Windows.Forms.Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap);
member this.SelectNextControl : System.Windows.Forms.Control * bool * bool * bool * bool -> bool
Public Function SelectNextControl (ctl As Control, forward As Boolean, tabStopOnly As Boolean, nested As Boolean, wrap As Boolean) As Boolean
Paramètres
- ctl
- Control
Control à partir duquel commencer la recherche.The Control at which to start the search.
- forward
- Boolean
true
pour se déplacer vers le bas dans l'ordre de tabulation ; false
pour se déplacer vers le haut dans l'ordre de tabulation.true
to move forward in the tab order; false
to move backward in the tab order.
- tabStopOnly
- Boolean
true
pour ignorer les contrôles dont la propriété TabStop a la valeur false
; sinon, false
.true
to ignore the controls with the TabStop property set to false
; otherwise, false
.
- nested
- Boolean
true
pour inclure les contrôles enfants imbriqués (enfants de contrôles enfants) ; sinon, false
.true
to include nested (children of child controls) child controls; otherwise, false
.
- wrap
- Boolean
true
pour poursuivre la recherche à partir du premier contrôle dans l'ordre de tabulation après que le dernier contrôle a été atteint ; sinon, false
.true
to continue searching from the first control in the tab order after the last control has been reached; otherwise, false
.
Retours
true
si un contrôle a été activé ; sinon, false
.true
if a control was activated; otherwise, false
.
Exemples
Le code suivant exemple la SelectNextControl méthode utilisée dans un formulaire qui contient des contrôles.The following code exampleshows the SelectNextControl method being used in a form that has some controls. Chaque fois que vous cliquez sur le formulaire, le contrôle suivant est activé.Each time that you click the form, the next control is activated. La ActiveControl propriété obtient le contrôle actuellement actif dans le contrôle conteneur.The ActiveControl property gets the currently active control in the container control.
private void Form1_Click(object sender, EventArgs e)
{
Control ctl;
ctl = (Control)sender;
ctl.SelectNextControl(ActiveControl, true, true, true, true);
}
Private Sub Form1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Click
Dim ctl As Control
ctl = CType(sender, Control)
ctl.SelectNextControl(ActiveControl, True, True, True, True)
End Sub
L’exemple de code suivant montre la SelectNextControl méthode utilisée dans un formulaire qui a un Button et d’autres contrôles.The following code example shows the SelectNextControl method being used in a form that has a Button and some other controls. Lorsque vous cliquez sur le Button , le contrôle suivant après l' Button activation de est activé.When you click the Button, the next control after the Button is activated. Notez que vous devez obtenir le parent du Button contrôle.Notice that you have to get the parent of the Button control. Étant donné que Button n’est pas un conteneur, l’appel SelectNextControl direct sur le ne Button modifie pas l’activation.Since Button is not a container, calling SelectNextControl directly on the Button would not change the activation.
private void button1_Click(object sender, EventArgs e)
{
Control p;
p = ((Button) sender).Parent;
p.SelectNextControl(ActiveControl, true, true, true, true);
}
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim p As Control
p = CType(sender, Button).Parent
p.SelectNextControl(ActiveControl, True, True, True, True)
End Sub
Remarques
La SelectNextControl méthode active le contrôle suivant dans l’ordre de tabulation si le bit de Selectable
style du contrôle a la valeur true
in ControlStyles , qu’il est contenu dans un autre contrôle, et que tous ses contrôles parents sont visibles et activés.The SelectNextControl method activates the next control in the tab order if the control's Selectable
style bit is set to true
in ControlStyles, it is contained in another control, and all its parent controls are both visible and enabled.
Les contrôles Windows Forms de la liste suivante ne peuvent pas être sélectionnés.The Windows Forms controls in the following list are not selectable. Les contrôles dérivés de contrôles dans la liste ne peuvent pas non plus être sélectionnés.Controls derived from controls in the list will also not be selectable.
LinkLabel (lorsqu’il n’y a aucun lien présent dans le contrôle)LinkLabel (when there is no link present in the control)
Lorsque vous modifiez le focus à l’aide du clavier (TAB, MAJ + TAB, etc.), en appelant les Select SelectNextControl méthodes ou, ou en définissant la ContainerControl.ActiveControl propriété sur le formulaire actuel, les événements de focus se produisent dans l’ordre suivant :When you change the focus by using the keyboard (TAB, SHIFT+TAB, and so on), by calling the Select or SelectNextControl methods, or by setting the ContainerControl.ActiveControl property to the current form, focus events occur in the following order:
Si la CausesValidation propriété a la valeur false
, les Validating Validated événements et sont supprimés.If the CausesValidation property is set to false
, the Validating and Validated events are suppressed.