locked
Checked item instead of selected item in checked list box RRS feed

  • Question

  • I'm having a bit of a problem with my if statement on my browser downloader checked list box at the moment.

    This is happening:

    If the selected item is "Google Chrome" Then a textbox's text should be "Google Chrome" 

    I want it to be:

    If the checked item is "Google Chrome" Then a textbox's text should be "Google Chrome" 

     

    My current code for this is:

            If boxBrowser.SelectedItem = "Google Chrome" Then
                devbox.Text = "Chrome"
            End If

    Thursday, November 3, 2011 6:16 PM

Answers

  • Well, since you want to find out if some item is checked, shouldn't you look in the checkeditems collection instead?

    Try this:

     If boxBrowser.CheckedItems.Contains("Google Chrome") Then
                devbox.Text = "Chrome"
            End If

    • Edited by Stanav Thursday, November 3, 2011 6:49 PM
    • Marked as answer by iJackr Thursday, November 3, 2011 8:39 PM
    Thursday, November 3, 2011 6:48 PM

All replies

  • Well, since you want to find out if some item is checked, shouldn't you look in the checkeditems collection instead?

    Try this:

     If boxBrowser.CheckedItems.Contains("Google Chrome") Then
                devbox.Text = "Chrome"
            End If

    • Edited by Stanav Thursday, November 3, 2011 6:49 PM
    • Marked as answer by iJackr Thursday, November 3, 2011 8:39 PM
    Thursday, November 3, 2011 6:48 PM
  • ...or simply use or override the checked event.

    Adam


    Already reported as abusive
    Thursday, November 3, 2011 6:52 PM
  • It worked! Thanks!
    Thursday, November 3, 2011 8:40 PM