yaniv Posted June 18, 2003 Posted June 18, 2003 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). Quote
Leaders dynamic_sysop Posted June 18, 2003 Leaders Posted June 18, 2003 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 Quote
yaniv Posted June 18, 2003 Author Posted June 18, 2003 but, this way i allways get the first item, can i set the selected item to be the one that the listbox currently show? Quote
Leaders dynamic_sysop Posted June 18, 2003 Leaders Posted June 18, 2003 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.