Member Avatar for Bo_1

If I doubleclick on a DirectoryListBox, Delphi returns the directory above the clicked one. A second doubleclick on the same directory returns the wanted directory. How do I select the intended directory in one doubleclick?
In the OnDblClick event I use Dir:=DirectoryListBox1.Directory. What am I doing wrong? Anybody?
Regards Bo

Recommended Answers

All 3 Replies

It is always a good idea to look at the source code in cases like this, if you have the VCL sources in your Delphi version. That way you can trace how the control responds to the double click.

Basically what is happening is that TDirectoryListBox fires off the onDblClick event before it changes the directory. This is so you can handle that event to do things for which you need to know which directory was selected before the change. If you want to know the directory after the change, handle the onChange event instead (or as well).

Member Avatar for Bo_1

Thank You very much! I thought it was someting like this, but I have struggled many years with this. I'll try the solution.
Regards Bo

Member Avatar for Bo_1

Tested and works very good, now I have learned me something new and essential.
Thank you very much, good to have Daniweb!
Regards Bo

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.