ADO DOT NET Posted November 4, 2007 Posted November 4, 2007 Hi, How can I select/unselect all items of a CheckedListBox ONLY VIA FOR EACH? This won't work for me: For Each Chk As CheckBox In FieldsCheckedListBox.Items Chk.Checked = True Next Thanks. Quote
Leaders snarfblam Posted November 5, 2007 Leaders Posted November 5, 2007 I don't think that this can generally be done via a for each loop. Unless you create your own class that references the CheckedListBox and can track/update its own checked status, and then populate the CheckedListBox with these, this can't be done. The problem is that a for each loop iterates through the items that you've added. Typically this is some sort of simple value like a simple string or integer, which, of course, don't expose the functionality to examine their status in any list-type control that may contain them. With the for each loop you are using, what you are asking for is impossible. Do you have a compelling reason to prefer a for each loop over a for next loop? Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.