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.
精彩评论