|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Select All CheckBoxesHow do I select all checkboxes on a TabControl in code? I have tried this, but the CHECKED property, doesn't work because its not part of the Control class Dim c As Control For Each c In Me.Controls If TypeOf c Is CheckBox Then c.Checked = True End If Next I have tried substituting the TabControl.Controls but still nothing I tried using a New statement after the If TypeOf line, but still no joy. Any Ideas what I am doing wrong? TIA Newbie Coder wrote:
> I have tried this, but the CHECKED property, doesn't work because its Try this:> not part of the Control class [...] \\\ Dim c As Control For Each c In Me.Controls If TypeOf c Is CheckBox Then DirectCast(c, CheckBox).Checked = True End If Next /// Because you know that c is of type CheckBox, you can safely cast it to that type. Then it will recognise that Checked is a valid property and set it without any problems. HTH, -- (O)enone Sorry, but your code doesn't check any checkboxes in the project
Show quoteHide quote "Oenone" <oen***@nowhere.com> wrote in message news:hLjch.1633$r95.42@newsfe6-win.ntli.net... > Newbie Coder wrote: > > I have tried this, but the CHECKED property, doesn't work because its > > not part of the Control class > [...] > > Try this: > > \\\ > Dim c As Control > For Each c In Me.Controls > If TypeOf c Is CheckBox Then > DirectCast(c, CheckBox).Checked = True > End If > Next > /// > > Because you know that c is of type CheckBox, you can safely cast it to that > type. Then it will recognise that Checked is a valid property and set it > without any problems. > > HTH, > > -- > > (O)enone > > Newbie Coder wrote:
> Sorry, but your code doesn't check any checkboxes in the project Well then, over to you to work out why not. :)Does the .Checked=True line get called at all? If not, why not? If it does, which control is contained in c? What is the value of c.Checked before and after the property is set? -- (O)enone
enter key press
best way to learn Windows Forms Upgrading Access 97 application to dotNet For loop variable date Merging two tables in Dataset? I only want to get the matching info based on the two key fields Working with a database How to set an objects property using Reflection PIAs for Excel 9.0 Make Code Fail How Do I Kill Non-Printable Characters? Enter Key vs. Tab Key |
|||||||||||||||||||||||