Results 1 to 3 of 3

Thread: [RESOLVED] [2005] Why does this not change???

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139

    Resolved [RESOLVED] [2005] Why does this not change???

    I have this code, but the text on button4 never changes when i click in my listbox

    Code:
    1. Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
    2.         Button4.Text = ListBox1.SelectedItem
    3.     End Sub

  2. #2
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: [2005] Why does this not change???

    Is this a Windows app or Web application??

    Furthermore, you forgot to add the handler of the selectedindexchanged event.

    Code should be:
    Code:
    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
    
            Button4.Text = ListBox1.SelectedItem
    
    End Sub
    Show Appreciation. Rate Posts.

  3. #3
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: [2005] Why does this not change???

    Try changing

    vb Code:
    1. Button4.Text= ListBox1.SelectedItem

    to

    vb Code:
    1. Button4.Text= ListBox1.Text
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width