Hi,
Could you I set the item in checkedlistbox is ticked?
Thanks,
NewBie
Printable View
Hi,
Could you I set the item in checkedlistbox is ticked?
Thanks,
NewBie
not sure I get your question. The checklistbox has a ItemCheck Event that you could put your code into it.
Example below:
Private Sub clbAnchoring_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles clbAnchoring.ItemCheck
'fire when the check box checked
mTxtBox.Anchor = AnchorStyles.None
Dim obj As Object
'Iterate through the checked items
For Each obj In clbAnchoring.CheckedItems
'AnchorStyles cannot be combined
'new value and old value are both combined
mTxtBox.Anchor = mTxtBox.Anchor Or _
DirectCast(obj, AnchorStyles)
Next
'If an items was just checked, it won't
'be in the checkeditmes yet
If e.NewValue = CheckState.Checked Then
mTxtBox.Anchor = mTxtBox.Anchor Or _
DirectCast(clbAnchoring.Items(e.Index), AnchorStyles)
'If an items was just unchecked, remove
'that AnchorStyles
ElseIf e.NewValue = CheckState.Unchecked Then
mTxtBox.Anchor = mTxtBox.Anchor And Not _
DirectCast(clbAnchoring.Items(e.Index), AnchorStyles)
End If
End Sub
Thanks for your Reply
NewBie