Link to home
Start Free TrialLog in
Avatar of Mike Littlewood
Mike LittlewoodFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How to focus a selected record in a TListView

I'm not sure if Im missing something obvious here, but is there a way to focus a selected item in a listview, and actually move the scrollbars down to put it in the screen?

I've got ListView.Selected, and if I move my scroll bars down manually, I can see the record is selected.

Problem is I can't seem to get the listview to actually move down to the selected record and automatically display it by moving its own scrollbars.

What am I missing?
ASKER CERTIFIED SOLUTION
Avatar of ZhaawZ
ZhaawZ
Flag of Latvia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BlackTigerX
BlackTigerX

supposing you wanted to make item 10 focused:

  ListView1.Items[10].MakeVisible(True);
  ListView1.Items[10].Selected:=True;
  ListView1.SetFocus
if you only want it focused, but not selected, change

ListView1.Items[10].Selected:=True;
by this:
ListView1.Items[10].Focused:=True;

try with both and see the difference

best regards
EberSys
Avatar of Mike Littlewood

ASKER

ah ha !

thanks guys