Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

when you create a list box and the user paging throw the items, the listbox.text always gives the same (the first) value.

The user has to "select" the item, "paint" it in blue- to get the item in the text.

 

Can you make the item in the listbox "autoselect", wich mean that the user don't has to touch the listbox again?

 

I found the "reselecting" very uneasy way (the user will usually click another button to make the form send the value to database or so).

  • Leaders
Posted
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       ListBox1.SelectedItem = ListBox1.Items.Item(1)
       '/// put your chosen item where it says 1
       MsgBox(ListBox1.SelectedItem)
   End Sub

  • Leaders
Posted

yes , the 1 that the listbox is currently showing is the SelectedIndex

this returns the item thats currently selected :

   Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
       If ListBox1.SelectedIndex < 0 Then Exit Sub
       ListBox1.SelectedItem = ListBox1.Items.Item(ListBox1.SelectedIndex)
       '/// put your chosen item where it says 1
       MsgBox(ListBox1.SelectedItem)
   End Sub

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...