problem with checkbox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • luca.gere

    problem with checkbox

    I have a problem.
    I'd like, when i click on a button , to check all the checkbox that i
    have in the form.

    I have tried with :

    For Each Myobj As Control In Me.Controls
    If TypeOf Myobj Is CheckBox Then
    If Myobj.checked Then
    ...
    ...
    ...
    End If
    End If
    Next

    but i have an error on myobj.checked :
    'checked' in not a member of 'system.windows .forms.controls '

    Thank you
    Luca

  • Al Reid

    #2
    Re: problem with checkbox

    "luca.gere" <luca.gere@gmai l.com> wrote in message news:1121871564 .007046.102080@ g44g2000cwa.goo glegroups.com.. .[color=blue]
    > I have a problem.
    > I'd like, when i click on a button , to check all the checkbox that i
    > have in the form.
    >
    > I have tried with :
    >
    > For Each Myobj As Control In Me.Controls
    > If TypeOf Myobj Is CheckBox Then[/color]

    Change the following line:[color=blue]
    > If Myobj.checked Then[/color]

    to:

    If CType(Myobj, CheckBox).check ed Then
    [color=blue]
    > ...
    > ...
    > ...
    > End If
    > End If
    > Next
    >
    > but i have an error on myobj.checked :
    > 'checked' in not a member of 'system.windows .forms.controls '
    >
    > Thank you
    > Luca
    >[/color]

    I hope that helps.

    --
    Al Reid


    Comment

    • luca.gere

      #3
      Re: problem with checkbox

      the line i use it to control re state of the check box and i'd like to
      chenge it.
      for example

      If Myobj.checked Then
      Myobj.checked=f alse
      else
      Myobj.checked=t rue
      endif

      Comment

      • Al Reid

        #4
        Re: problem with checkbox



        --
        Al Reid

        "It ain't what you don't know that gets you into trouble. It's what you know
        for sure that just ain't so." --- Mark Twain

        "luca.gere" <luca.gere@gmai l.com> wrote in message news:1121872507 .723611.220120@ f14g2000cwb.goo glegroups.com.. .[color=blue]
        > the line i use it to control re state of the check box and i'd like to
        > chenge it.
        > for example
        >
        > If Myobj.checked Then
        > Myobj.checked=f alse
        > else
        > Myobj.checked=t rue
        > endif
        >[/color]

        Perhaps the following instead:

        If TypeOf Myobj Is CheckBox Then
        Dim MyCheck As Checkbox = CType(Myobj, CheckBox)
        If MyCheck.checked Then
        MyCheck.checked =false
        Else
        MyCheck.checked =true
        End If
        End If

        Or maybe:

        If TypeOf Myobj Is CheckBox Then
        CType(Myobj, CheckBox).Check ed = Not CType(Myobj, CheckBox).Check ed
        End If

        I hope that helps.

        --
        Al Reid


        Comment

        • luca.gere

          #5
          Re: problem with checkbox

          perfect

          thank you :-)

          Comment

          Working...