Visualizzazione dei risultati da 1 a 7 su 7

Hybrid View

  1. #1
    Utente di HTML.it L'avatar di pietro09
    Registrato dal
    Jan 2002
    Messaggi
    10,116
    ci provo

    dipende cosa c'è dentro il listbox. Se ci sono stringhe, tipo per esempio:
    Me.ListBox1.Items.AddRange(New Object() {"", "Stefano", "Carlo", "Nicola", "Pietro", "Lucia"})

    farei così:
    codice:
    Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
        Dim c As ListBox = DirectCast(sender, ListBox)
        Dim item As String = c.SelectedItem.ToString
        If String.IsNullOrWhiteSpace(item) Then
            Label1.Text = "VUOTO"
        Else
            Label1.Text = "Non vuoto"
        End If
    End Sub
    Pietro

  2. #2
    Utente di HTML.it
    Registrato dal
    Mar 2014
    Messaggi
    131
    Quote Originariamente inviata da pietro09 Visualizza il messaggio
    ci provo

    dipende cosa c'è dentro il listbox. Se ci sono stringhe, tipo per esempio:
    Me.ListBox1.Items.AddRange(New Object() {"", "Stefano", "Carlo", "Nicola", "Pietro", "Lucia"})

    farei così:
    codice:
    Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
        Dim c As ListBox = DirectCast(sender, ListBox)
        Dim item As String = c.SelectedItem.ToString
        If String.IsNullOrWhiteSpace(item) Then
            Label1.Text = "VUOTO"
        Else
            Label1.Text = "Non vuoto"
        End If
    End Sub
    Funziona,grazie.

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.