On Feb 6, 5:59 am, "Armin Zingler" <az.nos...@freenet.de> wrote:
> <J...@aol.com> schrieb
>
> > I have three checkbox that I want to check the state (checkbox1
> > checkbox2 checkbox3
>
> > I do the following
>
> > Dim i As Integer
> > Dim chk As New CheckBox
> > For i = 1 To 3
> > chk = (Controls("CheckBox" & CStr(i)))
> > If chk.CheckState = CheckState.Unchecked Then .....Code
> > End If
> > Next
>
> > This works if the checkbox are NOT in a Panel only. Why??
>
> Because they are not controls in the Form but controls in the Panel. Use
> this instead:
>
> chk = YourPanel.Controls("CheckBox" & CStr(i))
>
> Armin
Just adding to Armin. If the only checkboxes your panel contains are
the checkboxes you want to investigate you could do this (as I hate
getting controls by name):
<pseudocode>
For each ctl as Control in YourPanel.Controls
If typeof(ctl) is Checkbox andalso directcast(ctl,
Checkbox).CheckState = CheckState.Unchecked then
' Do Stuff
End If
Next
</pseudocode>
Thanks,
Seth Rowe
|