Home All Groups Group Topic Archive Search About

Me.Controls CheckState

Author
22 Sep 2006 11:29 PM
aarrgghh765
Hi,

I'm using a counter to iterate through the CheckBox controls on my form
to set properties.

        For i = 1 To 48
            Me.Controls("X" & i.ToString).Enabled = False
        Next

My question is; why can't I set the CheckState in this way like

        For i = 1 To 48
            Me.Controls("X" & i.ToString).CheckState =
CheckState.Checked
        Next

Thanks.

Author
22 Sep 2006 11:41 PM
rzaleski
Your application doesn't know what type of control it is looking at.
You need to do this:

For i = 1 To 48
             CType(Me.Controls("X" & i.ToString), CheckBox).CheckState
= CheckState.Checked
Next

aarrgghh***@hotmail.com wrote:
Show quoteHide quote
> Hi,
>
> I'm using a counter to iterate through the CheckBox controls on my form
> to set properties.
>
>         For i = 1 To 48
>             Me.Controls("X" & i.ToString).Enabled = False
>         Next
>
> My question is; why can't I set the CheckState in this way like
>
>         For i = 1 To 48
>             Me.Controls("X" & i.ToString).CheckState =
> CheckState.Checked
>         Next
>
> Thanks.
Author
22 Sep 2006 11:55 PM
aarrgghh765
Thank you.

rzale***@gmail.com wrote:
Show quoteHide quote
> Your application doesn't know what type of control it is looking at.
> You need to do this:
>
> For i = 1 To 48
>              CType(Me.Controls("X" & i.ToString), CheckBox).CheckState
> = CheckState.Checked
> Next
>
> aarrgghh***@hotmail.com wrote:
> > Hi,
> >
> > I'm using a counter to iterate through the CheckBox controls on my form
> > to set properties.
> >
> >         For i = 1 To 48
> >             Me.Controls("X" & i.ToString).Enabled = False
> >         Next
> >
> > My question is; why can't I set the CheckState in this way like
> >
> >         For i = 1 To 48
> >             Me.Controls("X" & i.ToString).CheckState =
> > CheckState.Checked
> >         Next
> >
> > Thanks.