Closed Thread
Results 1 to 6 of 6

Thread: List box help

  1. #1
    2710 is offline Programmer
    Join Date
    Sep 2008
    Posts
    108
    Rep Power
    0

    List box help

    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!

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    2710 is offline Programmer
    Join Date
    Sep 2008
    Posts
    108
    Rep Power
    0

    Re: List box help

    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

  4. #3
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: List box help

    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]
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  5. #4
    2710 is offline Programmer
    Join Date
    Sep 2008
    Posts
    108
    Rep Power
    0

    Re: List box help

    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

  6. #5
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: List box help

    Glad I could help
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  7. #6
    Rustix666's Avatar
    Rustix666 is offline Newbie
    Join Date
    Dec 2009
    Posts
    15
    Rep Power
    0

    Re: List box help

    if ListBox1.ItemIndex <> -1 then
    if ListBox1.Items[ListBox1.ItemIndex] = 'blabla' then BlaBla;

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 10-01-2011, 01:45 PM
  2. List help
    By mr mike in forum Java Help
    Replies: 2
    Last Post: 02-09-2011, 07:12 PM
  3. i understand how change between list to list
    By Amjad Mobarki in forum C and C++
    Replies: 5
    Last Post: 01-27-2011, 11:52 AM
  4. Replies: 2
    Last Post: 06-28-2010, 08:45 PM
  5. A list of C++
    By Phoenixz in forum General Programming
    Replies: 3
    Last Post: 03-10-2009, 07:02 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts