Ok, a listbox scrolls whenever you change the listindex, but how do i do that with the listview, at least i would like to set the topindex manually
Printable View
Ok, a listbox scrolls whenever you change the listindex, but how do i do that with the listview, at least i would like to set the topindex manually
I normaly use the EnsureVisible method of the ListItem.
Damn, that simple, thanks anyway
EnsureVisible method does work - But in past experiences in using it, the selected item appears "somewhere" in the visible window of the listview. Is there a way to make a selected item appear at the first visible row of the listview?
Hmm, the topindex you mean? Oh, i'm sure there must be a way, i've seen it somewhere, but this time ensurevisible is good enough for me
Yes - The topindex basically.
In my application I have a textbox above the listview. Lets say the first listview column is "Last Name." In the keypress event of the textbox, I capture the contents of the textbox, then loop thru the listitems searching for the contents of the textbox. If I find it, I make that listitem the selecteditem, and ensure visibility on that item. Then I setfocus on the textbox and make sure the cursor is at the end of the text, waiting for the next key from the user. Basically the same functionality of IEs address bar. As you type the system tries to point you to the item you're looking for.
Problem with ensure visible in my application is that the listview is pretty tall. As you type and the selected item changes, when you ensure visible the selected item isn't always in the same place. It'd be nice to always have the selected item at the top.
I know this is somewhat picky, but we all know how end users can be at times.
later...
Try this, i'm not sure if it works with listview but it works with listbox...
Code:Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const LB_SETTOPINDEX = &H197
SendMessage ListBox1.hWnd, LB_SETTOPINDEX, newItemIndex, 0