Results 1 to 7 of 7

Thread: How to enable a button when an item is selected in a listBox

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    13

    How to enable a button when an item is selected in a listBox

    I'm stuck on a part of my assignment and wondering if someone could point me in the right direction.

    Here's my problem, I have set my listBox button_up to disabled, but I need it to enable when there is at least 1 selected item in the listBox, here's my code for the remove button:

    VB Code:
    1. Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
    2.  
    3.       If listBox.SelectedItems ' need selectedItem to = something??? Then
    4.  
    5.             Me.btnRemove.Enabled = True
    6.         End If
    7.  
    8.         Dim item As String = listBox.SelectedItem
    9.         Dim index As Integer = listBox.SelectedIndex
    10.         listBox.Items.RemoveAt(index)
    11.         listBox.Items.Insert(index - 1, item)
    12.         listBox.SelectedIndex = index - 1
    13.  
    14. end sub

    Thanks for any help.
    Last edited by JENKINS; Dec 9th, 2006 at 05:05 PM.

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