Forum > Beginners

TFileListBox Questions

(1/2) > >>

JLWest:
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.

jamie:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FileListBox1SelectionChange(Sender: TObject; User: boolean);begin  caption := FileListBox1.Items[FileListBox1.ItemIndex];end;                                                               

JLWest:
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.

 

jamie:
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  :)

molly:

--- Quote from: jamie on April 18, 2018, 03:13:56 am ---... there is a shortcut to that I just can't seem to remember..

--- End quote ---
By default it is ctrl-space right after you entered the dot.

Navigation

[0] Message Index

[#] Next page

Go to full version