Results 1 to 3 of 3

Thread: [RESOLVED] [02/03] CheckedListbox Question

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    115

    Resolved [RESOLVED] [02/03] CheckedListbox Question

    I add items to a checkedListbox from a file as such:

    Code:
     While Not myInputString Is Nothing
                    currentFields = Split(myInputString, ",")
                    If currentFields(1) = "0" Then
                        lstApts.Items.Add(currentFields(0))
    
                    Else
                        lstApts.Items.Add(currentFields(0))
                    '  I WANT TO CHECK THE ITEM THATS IN THIS ELSE CLAUSE
                    End If
                    rowCount += 1
                    ' Read the next line.
                    myInputString = myStreamReader.ReadLine()
                End While
    As I am adding the item to the checkedListbox I want to set its property to checked if it is in the "Else" clause above. My issue is that once I add the item how do I refer to the item I just added in order to set its property without having to iterate through the whole box?

  2. #2
    Hyperactive Member cptHotkeys's Avatar
    Join Date
    Apr 2007
    Location
    New Zealand
    Posts
    294

    Re: [02/03] CheckedListbox Question

    After you add an Item to the checked list box do this...
    Code:
    CheckedListBox1.Item(checkedlistbox1.items.count -1).checked = true

    Signatures suck

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    115

    Re: [02/03] CheckedListbox Question

    thanks.... i just found a simpler solution - the add method can be overloaded to take a second parameter - true or false

    Code:
    lstApts.Items.Add(currentFields(0), True)

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