开发者

Scroll Listview Items

开发者 https://www.devze.com 2022-12-28 09:04 出处:网络
I want to scroll the items on开发者_如何学JAVA the listview on the event of a button clik.is there any functionon .Net(Windows Application) for this? are you talking about the WPF Listview? Then the f

I want to scroll the items on开发者_如何学JAVA the listview on the event of a button clik.is there any function on .Net(Windows Application) for this?


are you talking about the WPF Listview? Then the following methods may help you:

ListView.BringIntoView ListView.ScrollIntoView

You can find information about these methods at:
http://msdn.microsoft.com/en-us/library/system.windows.controls.listview_members.aspx

Or you could set the property SelectedIndex, e.g.:
ListView.SelectedIndex = ListView.SelectedIndex + 1;

The last possibility i can imagine is to make the mousewheel-event of the listview fire, but i guess this is not recommended because WPF-Controls are lookless...


The most popular way is SendKeys Method. You must set a focus to your ListView and use SendKeys method. Then you can return focus to the button.


Something like this should work in WinForms:

ListView1.Items(newIndex).EnsureVisible()

You'd have to calculate newIndex so that it scrolled a suitable amount of rows.

0

精彩评论

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