hi all
I just want to know, how do I read the text from a list box. I have got a word, and I have like 10 lines in the list box. I want the delphi to 'search' the list box until the words match. So, i have used a for count up to 10, but I do not know how to 'read' from the Lisbox. i have got something like:
if 'textword' = listbox.???
then blah blah
Any help appreciated.
thanks!
Ok, Ive found out exactly what my problem is. I played around and realised that this:
Listbox1.Items.text
returns the whole listbox. I just want to ask, how do you read the line SELECTED, like, not EVERYTHING in the list box.
Thanks
PS.
Hmm this is kinda weird. I played around a bit more. Basically I programmed another simple form with just one listbox where I had the program put 'hello' into the listbox as soon as the form starts.
I then typed this(when a button is pressed):
If Listbox1.Items.text = 'Hello'
then
Showmessage ('yahoo')
else
Showmessage('bleh');
And guess what it showed me? 'bleh'
Why is this? I mean, dont both the listbox and what I typed match perfectly? So confusing!
Thanks
listbox.items is a TStrings. You can treat it like an array. The text property simply sends out ALL the items with line separators between them.
Re: Using the Delphi listbox
Delete Multiple Selected Items in a TListBox Delphi Control
Try testing ListBox1.items[ListBox1.itemindex]
hmm...doesnt that just give me the item at itemindex(watever) ? I want to 'read' the 'string' in the currently selected listbox. Since I dont know what item index its gonna be at (since I can click anything) I cant really use this way...can I?
Thanks for your reply anyways.
EDIT: Wait, the Listbox1.itemindex part IS the currently selected item right? Ok, let me fiddle around with this program, coz its till being a b**ch lol.
EDIT2: NEVERMIND. Dun it! Thanks![]()
Glad I could help![]()
if ListBox1.ItemIndex <> -1 then
if ListBox1.Items[ListBox1.ItemIndex] = 'blabla' then BlaBla;
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks