Using A CheckedListBox

G

Gobble.D.Gook

Could anybody help ne with this?

In VB6 / VBA, I could set up a listbox, with tickboxes/circles to the
side of each item. Selecting an Item caused the box to tick. Choosing
another deticked the original and ticekd the new one.

In .net, with a CheckedListBox with single selection, you can only
have obe item highlighted. But the ticks remain on previous items.

How can I just have one item selected and ticked ? And then I would
want to use that item to write to a file?

Thanks

D.
 
B

BluDog

How can I just have one item selected and ticked ? And then I would
want to use that item to write to a file?

When the ItemChecked event is fired, could you not just loop through
all the other items and uncheck them?
 
G

Gobble.D.Gook

When the ItemChecked event is fired, could you not just loop through
all the other items and uncheck them?

Seem to get into an endless loop doing that, as the event fires as I
change the checkstate ....
 
G

Gobble.D.Gook

OK, heres the answer, if anyone else wants to do this ...

Private Sub lstSupport_ItemCheck(ByVal sender As Object, ByVal e
As System.Windows.Forms.ItemCheckEventArgs) Handles
lstSupport.ItemCheck

If e.NewValue = CheckState.Checked Then
For Each i In lstSupport.CheckedIndices
lstSupport.SetItemChecked(i, False)
Next
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top