A
A
Alexander Vishnev2019-09-12 11:51:17
Delphi
Alexander Vishnev, 2019-09-12 11:51:17

How to programmatically click on a value in a Listbox?

There is a Listbox in which file names are loaded from the selected directory. By manually clicking on any line of the listbox, actions are performed with the file, upon completion of which this line is deleted along with it.
There are a lot of files and poking 100500 times is simply annoying. I decided to fasten a timer pusher that will click on the first line of the listbox every 10 seconds.
I tried to hang the code on the timer:
ListBox1.Selected[0]:=True;
But it compiles with an error and highlighting the above code: [dcc64 Error] Unit1.pas(99): E2149 Class does not have a default property

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Vishnev, 2019-09-12
@fromdns

ListBox1.ItemIndex := 0;
ListBox1.OnClick(nil)

K
kalapanga, 2019-09-12
@kalapanga

It is not clear, why do we need a timer and "pressing" here? Why not just call the desired procedure in a loop? It will be much more optimal in terms of time and safer. Suddenly 10 seconds is not enough for your operation - will everything be fine? And if the action is obviously shorter than 10 seconds, then a lot of time will be wasted on a large list.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question