Problem checking checkedlistbox

T

Trapulo

I've some problem checking items in a checkedlistbox by code:

For jj As Int32 = 0 To cbTimeOptions.Items.Count - 1

' cut: logic to set maycheck variable

cbTimeOptions.SetItemChecked(jj, maycheck )

Next

I've verified, dubbubg code, that after this for..next, cbTimeOptions has
two items checked. I've also verified, handling itemCheck event, that no
other code is changing this option after the for.

But my control hasn't item checked. Where is the error? How can I make other
useful tests?

thanks
 
H

Herfried K. Wagner [MVP]

* "Trapulo said:
I've some problem checking items in a checkedlistbox by code:

For jj As Int32 = 0 To cbTimeOptions.Items.Count - 1

' cut: logic to set maycheck variable

cbTimeOptions.SetItemChecked(jj, maycheck )

Next

I've verified, dubbubg code, that after this for..next, cbTimeOptions has
two items checked. I've also verified, handling itemCheck event, that no
other code is changing this option after the for.

But my control hasn't item checked. Where is the error? How can I make other
useful tests?

Can you create a little test project, upload it somewhere and post a
link?
 
P

Peter Huang

Hi Trapulo,

Thanks for posting in the community.

From your description, I know that when you set the checked state of a
checkedlistbox, the checkedlistbox control on the winform was not checked.

Did the problem persists when you just set the checked state with the hard
code state.
e.g.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.CheckedListBox1.SetItemChecked(1, True)
End Sub
After click the button, did the control was checked on the form.

Also can you simplify your code to reproduce the problem and post here or
send me a project by removing the "online" from my email address.

I look forward to hearing from you.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
T

Trapulo

Peter Huang said:
Hi Trapulo,

Thanks for posting in the community.

From your description, I know that when you set the checked state of a
checkedlistbox, the checkedlistbox control on the winform was not checked.
yes

Did the problem persists when you just set the checked state with the hard
code state.
e.g.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.CheckedListBox1.SetItemChecked(1, True)
End Sub
After click the button, did the control was checked on the form.

Yes, if I use this the control is checked
Also can you simplify your code to reproduce the problem and post here or
send me a project by removing the "online" from my email address.

I try. I don't know if I can because the application is a little complex...
 

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