Board index » delphi » Scrolling to a given position in a TListview

Scrolling to a given position in a TListview

Hi,

It's infuriating...  I would have thought there was an easy way to select an
item in a list view (using report mode) , set focus and then have that
selected item show in the box, if it is not currently visible then it should
come into view.

Below is the only way I have discovered to do this.

Does anyone have an elegant solution?

        with ListView do
        begin
                Selected := fli;        //this is found elsewhere
                idx := StrToInt(Selected.Caption) - 2;
                SendMessage(Handle,WM_KEYDOWN,VK_HOME,0);
                        //simulate the HOME key being pressed on the listview
                while idx > 0 do
                begin
                        SendMessage(Handle,WM_KEYDOWN,VK_DOWN,0);      
                                //simulate the DOWN key being pressed on the listview
                        dec(idx);
                end;
        end;
        Pages.ActivePage := InputPage;
        ListView.SetFocus;

Jim

 

Re:Scrolling to a given position in a TListview


"Jim Eadie" <jim_eadie@[take this out]mimotopes.com> skrev i melding
news:5l14qskgoo9dpjkba01j5rju5pikkvoh60@4ax.com...

Quote
> Hi,

> It's infuriating...  I would have thought there was an easy way to select
an
> item in a list view (using report mode) , set focus and then have that
> selected item show in the box, if it is not currently visible then it
should
> come into view.

> Below is the only way I have discovered to do this.

> Does anyone have an elegant solution?

Hi !

There is a method, but it's a method of TListItem, not TListView...

  procedure TListItem.MakeVisible(PartialOK: Boolean);

--
Bjoerge Saether
Consultant / Developer
Asker, Norway
bsaether.removet...@online.no (remove the obvious)

Re:Scrolling to a given position in a TListview


Thanks,

Exactly what I needed.

Jim

Quote
"Bj?rge S?ther" <REMOVE_bsaether@THIS_online.no> wrote:

>There is a method, but it's a method of TListItem, not TListView...

>  procedure TListItem.MakeVisible(PartialOK: Boolean);

Other Threads