-
September 23rd, 2013, 06:48 AM
#1
How can I auto scroll to SelectedIndex?
After I have selected a entry from my combo box and recorded it's selected index, and then clear and re-list the combo box, how can i then have the combo box scroll to the selected index that I have recorded?
Sorry if I am hard to understand, but I don't know all the techie talk.
Thank you.
I use VB.Net 2008 in all my wash, for those whiter whites.
-
September 23rd, 2013, 07:49 AM
#2
Re: How can I auto scroll to SelectedIndex?
This *almost* works, but you'll get the idea with which events to use and which properties of the CB to manipulate :
Code:
Public Class Form1
Private blnRecorded As Boolean
Private intNewIndex As Integer
Private arrComboItems() As String = {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"}
Private Sub ComboBox1_DropDown(sender As Object, e As System.EventArgs) Handles ComboBox1.DropDown
ComboBox1.Items.AddRange(arrComboItems)
If blnRecorded Then
ComboBox1.SelectedIndex = intNewIndex
blnRecorded = False
End If
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
intNewIndex = ComboBox1.SelectedIndex
ComboBox1.Items.Clear()
blnRecorded = True
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
MessageBox.Show(intNewIndex.ToString)
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
ComboBox1.Items.AddRange(arrComboItems)
End Sub
End Class
-
September 24th, 2013, 01:38 AM
#3
Re: How can I auto scroll to SelectedIndex?
Thanks, but with with this the item is selected, what I need is for the combo box to scroll to the area where the last selected index was without selecting it. If you get my drift?
I think in the old VB you had something like combobox1.listindex()
Last edited by dajunka; September 24th, 2013 at 03:42 AM.
I use VB.Net 2008 in all my wash, for those whiter whites.
-
September 24th, 2013, 02:45 PM
#4
Re:(SOLVED) How can I auto scroll to SelectedIndex?
For instance, let say I have 2 combobox and I want to take the selectedindex from the first one, then have the second combobox scroll to the same index but without the index being highlighted or selected.
Update: Okay I found a way.
Thank you.
Last edited by dajunka; September 25th, 2013 at 02:31 PM.
I use VB.Net 2008 in all my wash, for those whiter whites.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|