Reputation: 5349
I am working with List Box control in Vb.net , The problem is, I am populating List Box from a Slider control's values, At times, values reach out of its visible rectangle area. I want to see the updated values during slider move,I have added both the events
_SelectedIndexChanged
_SelectedValueChanged
but they both not triggering when I add values to List Box using Slider Control.
My tentative code for showing the latest value is this, but I am not getting where to type.
{
Dim count As Integer
count = lb.Items.Count ' lb is the ListBox's variable
lb.SetSelected(count - 1, True)
}
Upvotes: 3
Views: 139
Reputation: 38875
Depending on whether you want to just scroll to the bottom or select the last one:
lb.SelectedIndex =lb.SelectedIndex + 1
or to scroll it:
lb.TopIndex = lb.Items.Count - 1
add it after your code to add items. The latter is generally better because it doesnt change what the user might have selected already.
Upvotes: 2