开发者

How can I clear the focused item in a WinForms ListBox?

开发者 https://www.devze.com 2023-03-06 02:05 出处:网络
The ListBox is automatically scrolling to put the focused item in view when it redraws.But I don\'t want this to occur.I want the scroll position to stay as the user left it.So to do this, I think tha

The ListBox is automatically scrolling to put the focused item in view when it redraws. But I don't want this to occur. I want the scroll position to stay as the user left it. So to do this, I think that 开发者_运维问答I need to clear the focused item. But I don't see any way to do this.


The default behavior of a listbox is not to scroll the currently selected item into view. Usually you have to write some support code to do this.

If you are setting the selected index in code, the listbox will automatically scroll to that position. So look for any code where you're setting the selected item/index. You may need to save and restore the scroll position if you can't avoid setting the selected index.

0

精彩评论

暂无评论...
验证码 换一张
取 消