Home All Groups Group Topic Archive Search About

programatically created checkboxes within panels again....

Author
14 Jul 2006 8:01 AM
Mike Fellows
ok guys you have been a great help so far with this but im still struggling

I have some programatically created checkboxes within a panel

how can i set a checkbox to be actually checked (i.e. change its state)

currently im doing the following:


While count < DS4.Tables(0).Rows.Count
    While count2 < Me.Panel2.Controls.Count
        If DS4.Tables(0).Rows(count)(0) =
Me.Panel2.Controls.Item(count2).Text.ToString Then

            'NEED SOME CODE TO SET THE CHECKBOX WITHIN THE PANEL TO CHECKED

        End If
        count2 = count2 + 1
    End While
count2 = 0
count = count + 1
End While

Basically im looping through a dataset to see if the value in the dataset is
the same as the text on a checkbox, if it is i need to set the checkbox to
checked, but i have no idea how to do it

Thanks

Mike Fellows

Author
14 Jul 2006 9:15 AM
Mike Fellows
I managed to do this, very simply in all honesty

by doing the following

Dim cbx As CheckBox
cbx = Me.Panel2.Controls.Item(count2)
cbx.Checked = True
Me.Panel2.Controls.RemoveAt(count2)
Me.Panel2.Controls.Add(cbx)



Thanks though





Show quoteHide quote
"Mike Fellows" <michael.fellows@equityhouse.NOSPAM.co.uk> wrote in message
news:yLqdnZInO9L80irZnZ2dneKdnZydnZ2d@giganews.com...
> ok guys you have been a great help so far with this but im still
> struggling
>
> I have some programatically created checkboxes within a panel
>
> how can i set a checkbox to be actually checked (i.e. change its state)
>
> currently im doing the following:
>
>
> While count < DS4.Tables(0).Rows.Count
>    While count2 < Me.Panel2.Controls.Count
>        If DS4.Tables(0).Rows(count)(0) =
> Me.Panel2.Controls.Item(count2).Text.ToString Then
>
>            'NEED SOME CODE TO SET THE CHECKBOX WITHIN THE PANEL TO CHECKED
>
>        End If
>        count2 = count2 + 1
>    End While
> count2 = 0
> count = count + 1
> End While
>
> Basically im looping through a dataset to see if the value in the dataset
> is the same as the text on a checkbox, if it is i need to set the checkbox
> to checked, but i have no idea how to do it
>
> Thanks
>
> Mike Fellows
>
Author
14 Jul 2006 2:53 PM
Terry
Hi Mike,
   In your code, cbx and Me.Panel2.Controls.Items(count2) are references to
the same object - what is the point in removing and then adding the same
checkbox to the collection?
Why don't you just:
Ctype(Me.Panel2.Controls.Items(count2), CheckBox).Checked = True

--
Terry


Show quoteHide quote
"Mike Fellows" wrote:

> I managed to do this, very simply in all honesty
>
> by doing the following
>
> Dim cbx As CheckBox
> cbx = Me.Panel2.Controls.Item(count2)
> cbx.Checked = True
> Me.Panel2.Controls.RemoveAt(count2)
> Me.Panel2.Controls.Add(cbx)
>
>
>
> Thanks though
>
>
>
>
>
> "Mike Fellows" <michael.fellows@equityhouse.NOSPAM.co.uk> wrote in message
> news:yLqdnZInO9L80irZnZ2dneKdnZydnZ2d@giganews.com...
> > ok guys you have been a great help so far with this but im still
> > struggling
> >
> > I have some programatically created checkboxes within a panel
> >
> > how can i set a checkbox to be actually checked (i.e. change its state)
> >
> > currently im doing the following:
> >
> >
> > While count < DS4.Tables(0).Rows.Count
> >    While count2 < Me.Panel2.Controls.Count
> >        If DS4.Tables(0).Rows(count)(0) =
> > Me.Panel2.Controls.Item(count2).Text.ToString Then
> >
> >            'NEED SOME CODE TO SET THE CHECKBOX WITHIN THE PANEL TO CHECKED
> >
> >        End If
> >        count2 = count2 + 1
> >    End While
> > count2 = 0
> > count = count + 1
> > End While
> >
> > Basically im looping through a dataset to see if the value in the dataset
> > is the same as the text on a checkbox, if it is i need to set the checkbox
> > to checked, but i have no idea how to do it
> >
> > Thanks
> >
> > Mike Fellows
> >
>
>
>
Author
17 Jul 2006 8:07 AM
Mike Fellows
Because I didnt know how to do that

but that is much better than my way

Thanks




Show quoteHide quote
"Terry" <Terry@nospam.nospam> wrote in message
news:58378FE8-F149-4FA9-9ED0-D85A1F89E619@microsoft.com...
> Hi Mike,
>   In your code, cbx and Me.Panel2.Controls.Items(count2) are references to
> the same object - what is the point in removing and then adding the same
> checkbox to the collection?
> Why don't you just:
> Ctype(Me.Panel2.Controls.Items(count2), CheckBox).Checked = True
>
> --
> Terry
>
>
> "Mike Fellows" wrote:
>
>> I managed to do this, very simply in all honesty
>>
>> by doing the following
>>
>> Dim cbx As CheckBox
>> cbx = Me.Panel2.Controls.Item(count2)
>> cbx.Checked = True
>> Me.Panel2.Controls.RemoveAt(count2)
>> Me.Panel2.Controls.Add(cbx)
>>
>>
>>
>> Thanks though
>>
>>
>>
>>
>>
>> "Mike Fellows" <michael.fellows@equityhouse.NOSPAM.co.uk> wrote in
>> message
>> news:yLqdnZInO9L80irZnZ2dneKdnZydnZ2d@giganews.com...
>> > ok guys you have been a great help so far with this but im still
>> > struggling
>> >
>> > I have some programatically created checkboxes within a panel
>> >
>> > how can i set a checkbox to be actually checked (i.e. change its state)
>> >
>> > currently im doing the following:
>> >
>> >
>> > While count < DS4.Tables(0).Rows.Count
>> >    While count2 < Me.Panel2.Controls.Count
>> >        If DS4.Tables(0).Rows(count)(0) =
>> > Me.Panel2.Controls.Item(count2).Text.ToString Then
>> >
>> >            'NEED SOME CODE TO SET THE CHECKBOX WITHIN THE PANEL TO
>> > CHECKED
>> >
>> >        End If
>> >        count2 = count2 + 1
>> >    End While
>> > count2 = 0
>> > count = count + 1
>> > End While
>> >
>> > Basically im looping through a dataset to see if the value in the
>> > dataset
>> > is the same as the text on a checkbox, if it is i need to set the
>> > checkbox
>> > to checked, but i have no idea how to do it
>> >
>> > Thanks
>> >
>> > Mike Fellows
>> >
>>
>>
>>