Visualizzazione dei risultati da 1 a 5 su 5

Visualizzazione discussione

  1. #1

    [VB.NET] CheckedChanged & CheckedStateChanged

    In allegato c'è il form per essere più chiari (non cosiderate la CheckBox1 è li per far delle prove).

    Al caricamento del form aggiungo delle checkbox dentro il pannello nel seguente modo:

    codice:
             Try
                Using File As StreamReader = New StreamReader("Elenco_alunni.txt")
                    Alunno = File.ReadLine()
                    Do
                        Dim Check As New CheckBox
                        With Check
                            .AutoSize = True
                            .Text = Alunno
                            .Location = New Point(.Location.X, Altezza)
                            Altezza = Altezza + .Height + 2
                            .Visible = True
                            .Enabled = True
                            .Name = Alunno
                        End With
                        Pnl_alunni.Controls.Add(Check)
                        AddHandler Check.CheckedChanged, AddressOf Check_CheckedChanged
                        i = i + 1
                        Alunno = File.ReadLine()
                    Loop Until Alunno Is Nothing
                End Using
            Catch Err As Exception
                MsgBox(Err.ToString, 0)
            End Try
    Fin qui tutto ok.

    Adesso io voglio sapere quale checkbox l'utente "spunta" e quindi devo gestire uno dei due eventi in titolo, io ho utilizzato CheckedChanged:

    codice:
        Private Sub Check_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
            'MsgBox(sender.GetType.GetProperty(Name))
            'MsgBox(e.GetType.GetProperty(Text))
        End Sub

    PROBLEMA: come faccio ad ottenere il testo della checkbox che scatena l'evento?
    [Ho provato con quelle due righe di codice commentato ma entrambe ritornano un valore null]
    Grazie in aticipo, ciao!
    Immagini allegate Immagini allegate

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.