Domanda

In Visual Studio whenever you select an item, the item become highlighted. I want to take advantage of this property to retrieve the checked item that is currently being highlighted (out of all the item in the checkedlistbox)

Is this operation possible?

È stato utile?

Soluzione

The CheckedListBox control always seemed rather half-baked to me, so I don't use it often.

Something like this works:

With CheckedListBox1
  If .SelectedIndex > -1 Then
    If .CheckedIndices.Contains(.SelectedIndex) Then
      MessageBox.Show(.SelectedItem.ToString & " is checked.")
    Else
      MessageBox.Show(.SelectedItem.ToString & " is not checked.")
    End If
  End If
End With
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top