1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| Private Sub CheckBox22_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox22.CheckedChanged, CheckBox23.CheckedChanged, CheckBox24.CheckedChanged, CheckBox25.CheckedChanged, CheckBox26.CheckedChanged, CheckBox27.CheckedChanged, CheckBox28.CheckedChanged, CheckBox29.CheckedChanged, CheckBox30.CheckedChanged, CheckBox31.CheckedChanged, CheckBox32.CheckedChanged, CheckBox33.CheckedChanged, CheckBox34.CheckedChanged, CheckBox35.CheckedChanged, CheckBox36.CheckedChanged, CheckBox37.CheckedChanged, CheckBox38.CheckedChanged, CheckBox39.CheckedChanged, CheckBox40.CheckedChanged, CheckBox41.CheckedChanged, CheckBox42.CheckedChanged, CheckBox43.CheckedChanged // Attention très important de mettre votre code dans toutes les checkboxs du panel si il y a pleins d'erreurs ou cela ne marche pas tout simplement
Dim tx As Integer
Dim ctl As Control
Dim tex As Control
For Each ctl In Me.pnlcheck3.Controls // Pour chaque controle du panel
If TypeOf sender Is CheckBox And sender.checked = True Then // On regarde le type du sender(le controle clicker ou cocher par exemple) et si ce sender et une checkbox on regarde si elle est cochée
tx = sender.TabIndex + 1 // si oui alors on lie le controle correspondant à la checkbox grace a tabindex (car control.tabindex = sender.tabindex+1)
For Each tex In Me.pnltex3.Controls
If TypeOf tex Is TextBox And tex.TabIndex = tx Then // on cherche les controls qui sont de type textbox et on recherche le control.tabindex = sender.tabindex+1 vu precedement
tex.Enabled = True // une fois qu'on la trouvé on change sa propriété enabled dans ce cas.
End If
Next
// idem pour ce qui suit c'est le même code avec des changement de valeur pour la checkbox et pour letat "enabled" du control
ElseIf TypeOf sender Is CheckBox And sender.checked = False Then
tx = sender.TabIndex + 1
For Each tex In Me.pnltex3.Controls
If TypeOf tex Is TextBox And tex.TabIndex = tx Then
tex.Enabled = False
End If
Next
End If
Next |
Partager