Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a CheckedListBox that has some items already checked, while other items are not. This entire CheckedListBox should be Read Only. Unfortunately, the Locked property does not seem to produce that effect.

 

Any ideas on locking the CheckedState of a CheckedListBox?

"Never ascribe to malice that which can adequately be explained by incompetence." -- Napolean Bonaparte
Posted
Read up on the Locked property. It is design-time only and prevents a control being moved or resized by drag-and-drop in the designer.
    Private checkAllowed As Boolean = False

   Private Sub CheckedListBox1_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles CheckedListBox1.ItemCheck
       If Not Me.checkAllowed Then
           e.NewValue = e.CurrentValue
       End If
   End Sub

Whenever you want to check or uncheck an item programmatically, you have to set the checkAllowed variable to True first, and then back to False afterwards.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...