Results 1 to 5 of 5

Thread: Help with retrieving text from a Check List Box -> Resolved

  1. #1

    Thread Starter
    Frenzied Member RudyL's Avatar
    Join Date
    Mar 2001
    Location
    Chicago
    Posts
    1,519

    Resolved Help with retrieving text from a Check List Box -> Resolved

    I am using a checked list box but for some reason I can not ficure out how to retrieve the text from a specific index...

    I tried this

    clbModels.GetItemText(1)

    but all I get is the index back... Any ideas?
    Last edited by RudyL; Dec 8th, 2004 at 03:17 PM.
    10 different ways to skin a cat and amazingly enough each and every one has the same result, the cat gets skinned! The same can be applied to code, so be nice and accept each others "preferences".

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Help with retrieving text from a Check List Box

    try
    Code:
    CheckedListBox1.Items(x).ToString()
    x being the index

  3. #3

    Thread Starter
    Frenzied Member RudyL's Avatar
    Join Date
    Mar 2001
    Location
    Chicago
    Posts
    1,519

    Re: Help with retrieving text from a Check List Box

    Quote Originally Posted by kleinma
    try
    Code:
    CheckedListBox1.Items(x).ToString()
    x being the index
    Thanks.. That works beautifuly..

    So what exaclt is "GetItemText" for? According to the object browser it should do the same thing..
    "Summary:
    Returns the text representation of the specified item.

    Parameters:
    item: The object from which to get the contents to display. "
    10 different ways to skin a cat and amazingly enough each and every one has the same result, the cat gets skinned! The same can be applied to code, so be nice and accept each others "preferences".

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Help with retrieving text from a Check List Box -> Resolved

    object browser = poo
    msdn = yay

    basically it does the same exact thing... BUT if you look at the help file on MSDN, the param you pass to the GetItemText method is not the index... its the object itself...
    item
    The object from which to get the contents to display.
    so it makes sense that you pass the object "1" to it, that it spits it right back at you, because its simply calling ToString on "1", which gives you.. well.. "1"

    so if you have the OBJECT in question (since listboxes can hold objects, not just text, but can only display the ToString of the objects they hold) using the method I gave is simply the easiest way to go about it

  5. #5

    Thread Starter
    Frenzied Member RudyL's Avatar
    Join Date
    Mar 2001
    Location
    Chicago
    Posts
    1,519

    Re: Help with retrieving text from a Check List Box -> Resolved

    Sounds good to me..

    Thanks again,
    Rudy
    10 different ways to skin a cat and amazingly enough each and every one has the same result, the cat gets skinned! The same can be applied to code, so be nice and accept each others "preferences".

Posting Permissions

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



Click Here to Expand Forum to Full Width