3

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) 
}
4

1 回答 1

2

根据您是要滚动到底部还是选择最后一个:

lb.SelectedIndex =lb.SelectedIndex + 1

或滚动它:

lb.TopIndex = lb.Items.Count - 1

在您的代码之后添加它以添加项目。后者通常更好,因为它不会改变用户可能已经选择的内容。

于 2013-11-05T12:28:50.240 回答