I have a CheckedListBox where some of the items are checked and some are
not. I want the CheckState to be Read Only. Unfortunately, the Locked
property doesn't seem to prevent the user from changing the CheckState.

The CheckedListBox is on a Tab Control if that makes any difference. Any
help is greatly appreciated.

carl

RE: How to lock CheckState in CheckedListBox? by Shariq

Shariq
Thu Jul 14 11:49:05 CDT 2005

You could use the ItemCheck property of the CheckedListBox control

Private Sub MyCheckList_ItemCheck(ByVal sender As Object, ByVal e As
System.Windows.Forms.ItemCheckEventArgs) Handles lstLabelTypes.ItemCheck
if e.CurrentValue=1 then
e.NewValue=1
end if

"Vagabond Software" wrote:

> I have a CheckedListBox where some of the items are checked and some are
> not. I want the CheckState to be Read Only. Unfortunately, the Locked
> property doesn't seem to prevent the user from changing the CheckState.
>
> The CheckedListBox is on a Tab Control if that makes any difference. Any
> help is greatly appreciated.
>
> carl
>
>
>

Re: How to lock CheckState in CheckedListBox? by Vagabond

Vagabond
Fri Jul 15 09:48:57 CDT 2005

"Shariq" <Shariq@discussions.microsoft.com> wrote in message
news:B030F19D-45FE-4C22-81F5-E60549FB21B8@microsoft.com...
> You could use the ItemCheck property of the CheckedListBox control
>
> Private Sub MyCheckList_ItemCheck(ByVal sender As Object, ByVal e As
> System.Windows.Forms.ItemCheckEventArgs) Handles lstLabelTypes.ItemCheck
> if e.CurrentValue=1 then
> e.NewValue=1
> end if

Thanks, that works with one caveat. The ItemCheck event fires even when
programmatically changing the CheckState. So, I also added a private bool
(checkStateLocked) that I could change when I want to alter the CheckState
programmatically. So the ItemCheck event block looks like this:

if (checkStateLocked) then
e.NewValue = e.CurrentValue;

Thanks again for your help.

Regards,

carl