Scroll to selected items in Checked List Box

dsm1995gst

Member
Joined
Apr 29, 2011
Messages
16
Programming Experience
1-3
I've got a Checked List Box full of PC names that the user can check. I've also got a Combo Box that lists the location of the PCs - if the user chooses one of the locations in the Combo Box, it automatically selects all of the PCs in the Checked List Box that are at that location.

However, if that group of PCs are way down the list in the Checked List Box, you can't immediately see that they were checked.

I'd like to know if there was a way to have the application automatically scroll/jump down to the area of the Checked List Box containing the PC's that were just checked.

Thanks.
 
To make first checked item appear you can select it:
VB.NET:
Me.CheckedListBox1.SelectedIndex = Me.CheckedListBox1.CheckedIndices(0)
This will just bring it into view, ie as last visible item. If you want to make it as close to top as possible you can first select last item:
VB.NET:
Me.CheckedListBox1.SelectedIndex = Me.CheckedListBox1.Items.Count - 1
then select first checked as above.
 
To make first checked item appear you can select it:
VB.NET:
Me.CheckedListBox1.SelectedIndex = Me.CheckedListBox1.CheckedIndices(0)
This will just bring it into view, ie as last visible item. If you want to make it as close to top as possible you can first select last item:
VB.NET:
Me.CheckedListBox1.SelectedIndex = Me.CheckedListBox1.Items.Count - 1
then select first checked as above.
Thanks for the help, this is what I was looking for.

Now if the user selects a location in the combo box, it automatically selects the PCs for that location in the checkedlistbox and jumps down in the list to those PCs.

The problem is, if the user goes back and selects another location in the combo box, it properly selects those PCs in the checkedlistbox, but it once again jumps to the first selected item (just as we told it to do), whereas I would actually want it to jump to the specific group of PCs that were just selected.

If I understand this method correctly it looks like what I'm trying to do might just not be possible, at least not this way.
 
Since you have the index of the item you checked so you can set SelectedIndex to that.
 
Back
Top