Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    [vb.net]group box enabled false

    RAGA VORREI SAPERE UNA COSA!
    Ho un group box che contiene 12 CheckBox.
    Io vorrei fare in modo che se sono selezionati più di 2 CheckBox. il group box si disattivi
    cioè il valore enabled diventi false.
    come posso fare per far capire che se sono selezionati 2 checkbox si disattivi l'intero groupBox?
    grazie

  2. #2
    Direi che potresti fare una cosa tipo questa:
    codice:
        Private Sub ControllaStato()
            Dim c As Control
            Dim ck As CheckBox
            Dim n As Integer
    
            For Each c In GroupBox1.Controls
                If TypeOf c Is CheckBox Then
                    ck = c
                    If ck.Checked Then n += 1
                End If
            Next
    
            If n = 2 Then GroupBox1.Enabled = False
        End Sub
    
        Private Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
            ControllaStato()
        End Sub
    
        Private Sub CheckBox2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
            ControllaStato()
        End Sub
    
        Private Sub CheckBox3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
            ControllaStato()
        End Sub
    Ciao
    Chi non cerca trova.

  3. #3
    grazie mille tas.
    funziona perfettamente
    ciao

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.