* * *

Author Topic: TFileListBox Questions  (Read 1199 times)

JLWest

  • Full Member
  • ***
  • Posts: 192
TFileListBox Questions
« on: April 18, 2018, 01:00:30 am »
I have a TFileListbox on a form.
It's set to a directory and I can see files listed in the listbox.

However I can't see any way to click on one of the names in the TFileListBox  I clicked on into a variable such as MySelect : String;

What am I missing here.

JLWEST 
 FPC 3.0.4, Lazarus IDE v1.8.2 Windows 10 Pro
 Intel i7 770K CPU 4.2GHz 16 Gig Ram
GeForce GTX 1080 Graphics - 8 Gig 1.5 Terabyte SSD

jamie

  • Hero Member
  • *****
  • Posts: 835
Re: TFileListBox Questions
« Reply #1 on: April 18, 2018, 01:25:34 am »
implement one of the events.

for example,
 
 OnSelectionChange
 
  That has a USER Boolean it that informs you if a USER clicked it or your software may have selected it directly..

 You have ITEMS which is a stringlist and ItemIndex which  points to the string in the list via the user selection.

Code: Pascal  [Select]
  1. procedure TForm1.FileListBox1SelectionChange(Sender: TObject; User: boolean);
  2. begin
  3.   caption := FileListBox1.Items[FileListBox1.ItemIndex];
  4. end;
  5.                                                              
  6.  

JLWest

  • Full Member
  • ***
  • Posts: 192
Re: TFileListBox Questions
« Reply #2 on: April 18, 2018, 01:54:38 am »
Worked perfect, However I don't really understand why.

Both "Items" and "Caption" are not listed as a property under TFileListBox.

 Caption := FileListBox.Items[FileListBox.ItemIndex];

So how do you know to use those?

Thanks for the help.

 
JLWEST 
 FPC 3.0.4, Lazarus IDE v1.8.2 Windows 10 Pro
 Intel i7 770K CPU 4.2GHz 16 Gig Ram
GeForce GTX 1080 Graphics - 8 Gig 1.5 Terabyte SSD

jamie

  • Hero Member
  • *****
  • Posts: 835
Re: TFileListBox Questions
« Reply #3 on: April 18, 2018, 03:13:56 am »
The HELP file is a wondering thing... ;)

 Normally any object/Class that has some relationship with arrays of some type, in this case strings, will
have the property "ITEMS" that represents the data in an array sort of way and will also have a ItemIndex that
points you to the currently selected ITEM in the ITEMS property..

  As for the name tags not being seen in the Object inspector, that is due to the fact that ITEMS and ItemIndex are not
Published in the Class define. But they are PUBIC which means you have access to them at runtime..

 For this Component/Control it makes no sense to have the ITEMS published in the object inspector because any data
you would put there at design time gets overwritten at runtime, so its a pointless and waste of Resource space in the EXE file.

But getting back to the HELP FILE, it works, it shows you all of this..

Also, you can use the CODE complete function like I do...
Keyboard type :
  MYFileLISTBOX.  and wait for the list of accessible members to show.., there is a shortcut to that I just can't seem to remember..

BTW,

 I use "Caption" which is just the caption of your form as a test display output...that's all  :)
« Last Edit: April 18, 2018, 03:16:02 am by jamie »

molly

  • Hero Member
  • *****
  • Posts: 2345
Re: TFileListBox Questions
« Reply #4 on: April 18, 2018, 03:18:47 am »
... there is a shortcut to that I just can't seem to remember..
By default it is ctrl-space right after you entered the dot.

JLWest

  • Full Member
  • ***
  • Posts: 192
Re: TFileListBox Questions
« Reply #5 on: April 18, 2018, 05:32:12 am »
I can never get help to show me anything.

I go to the top and click on help.

I do a search for TFileListbox and get No Results.

Or go to the  Online help and do the same search and I get the form. No Information about TFilelist.

So if there is a secret to using help please share.





JLWEST 
 FPC 3.0.4, Lazarus IDE v1.8.2 Windows 10 Pro
 Intel i7 770K CPU 4.2GHz 16 Gig Ram
GeForce GTX 1080 Graphics - 8 Gig 1.5 Terabyte SSD

Handoko

  • Hero Member
  • *****
  • Posts: 2598
  • My goal: build my own game engine using Lazarus
Re: TFileListBox Questions
« Reply #6 on: April 18, 2018, 08:47:01 am »
I do not use the help provided by the IDE. I remember last time I used it, it didn't show anything I need.

Here are some useful tips:

1. Use the hint provided by the Source Editor

In the Source Editor window, move your mouse pointer to the text you need help. Wait some seconds, a hint will be popped up. See img1, that was the example of hint when I put my mouse pointer on the text "Caption".

2. Use the info box in the Object Inspector

You need to enable it first:
Lazarus main menu > Tools > Options > Environment > Object Inspector > enable the Show information box

On the img2, you can see the show information box appeared at the bottom of the Object Inspector if the "Caption" property is selected.

3. Use [Ctrl + Space]

As mentioned by @molly, I use it a lot. Especially to make sure the property I type is available for the object, also it will automatically fix the case of the keyword you type. But if I want to know more information about the class/property/procedure/function, I use tip #4 below.

4. Use [Ctrl + click]

It may be useful only if you're good in Pascal language. In the Source Editor window, do Ctrl + click on the text you need to know more. You may need to do it repeatedly several times and maybe combine with [Shift + Ctrl + Down]. It will show you the source code of the selected class or property or procedure or function or type declaration. Very useful, it gives you the idea what it does or how it done.

5. Use Google search

If I want to know more about TFileListBox, I will search with query "Lazarus TFileListBox".



Lazarus IDE is full of 'hidden' features, the more you know it the more you will like it.
« Last Edit: April 18, 2018, 08:57:09 am by Handoko »

jamie

  • Hero Member
  • *****
  • Posts: 835
Re: TFileListBox Questions
« Reply #7 on: April 18, 2018, 11:29:07 pm »
The help does not open to all of the different subjects on initial opening..
Open Help

go to FILE :OPEN : and it should take you to a list of help files, if you don't see it then propagate
to the DOCS:chm  folder in LAZARUS where you'll find all these help files...

 For visual control help, OPEN the LCL help file...
 For things more related to the compiler itself, like functions that have nothing to do with visual effects you
open the RTL .(run time library)

 Once you have propagated to this folder the first time, it will remember the path but, it seems that every time you
open the Help function the OPEN RECENTLY does not remember all of the help files you used last time, so you'll need to
do OPEN and then select one of the help files of interest...

 Remember that LCL.chm is for the visual control you play with on the screen..

 There are others I there too.


 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus