Board index » delphi » Is there a way ? (filelistbox)

Is there a way ? (filelistbox)

Hi to all and thanks for any replay.

If a filelistbox has the focus and I  press a key, then the first file
starting with this key appears highlighted at the bottom of the
listbox.

 I want the file to move to the top of the list box.

In the moment I reading the itemindex in a Onchange event and pass it
on in a keydown event (Listbox.topindex). It doesn't work as planned.

If I press a key, it is on the bottom as before but moves then to the
top when I press the same key again.

Any ideas on this?
Regards Gery

www.zipworld.com.au~gprdata

 

Re:Is there a way ? (filelistbox)


Gery Rohrig schrieb:

Quote
> If a filelistbox has the focus and I  press a key, then the first file
> starting with this key appears highlighted at the bottom of the
> listbox.

>  I want the file to move to the top of the list box.

It sounds a bit strange what you plan to do, but anyway, try this:

procedure TForm1.ListBox1Click(Sender: TObject);
begin
  if ListBox1.ItemIndex >= 0 then begin
    ListBox1.Items.Move(ListBox1.ItemIndex, 0);
    ListBox1.ItemIndex := 0;
  end;
end;

-Michael

Other Threads