473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Dynamically created checkboxes within a panel - how do i get the value?

I have created some checkboxes within a panel using the code below
Dim NewCheckbox As New CheckBox
Me.Panel2.Controls.Add(NewCheckbox)
NewCheckbox.Location = New Point(XLocation, YLocation)
NewCheckbox.AutoSize = True
NewCheckbox.Text = DS1.Tables(0).Rows(counter1)(0)
NewCheckbox.Name = "Checkbox" & counter1 + 1

the problem I have is how do i access the value of that checkbox? (usually
it would be just checkbox1.checked, but obvioulsy this does not work)

Thanks

Mike Fellows
Jul 13 '06 #1
5 8355

use a for loop
and before this name ur controls prperly.
Asad

Mike Fellows wrote:
I have created some checkboxes within a panel using the code below
Dim NewCheckbox As New CheckBox
Me.Panel2.Controls.Add(NewCheckbox)
NewCheckbox.Location = New Point(XLocation, YLocation)
NewCheckbox.AutoSize = True
NewCheckbox.Text = DS1.Tables(0).Rows(counter1)(0)
NewCheckbox.Name = "Checkbox" & counter1 + 1

the problem I have is how do i access the value of that checkbox? (usually
it would be just checkbox1.checked, but obvioulsy this does not work)

Thanks

Mike Fellows
Jul 13 '06 #2
maybe you should read before posting

and atleast attempt to spell correctly

the checkbox names i gave where an example

and the for loop is fairly obvious, but again that was not my question!


<as********@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
>
use a for loop
and before this name ur controls prperly.
Asad

Mike Fellows wrote:
>I have created some checkboxes within a panel using the code below
Dim NewCheckbox As New CheckBox
Me.Panel2.Controls.Add(NewCheckbox)
NewCheckbox.Location = New Point(XLocation, YLocation)
NewCheckbox.AutoSize = True
NewCheckbox.Text = DS1.Tables(0).Rows(counter1)(0)
NewCheckbox.Name = "Checkbox" & counter1 + 1

the problem I have is how do i access the value of that checkbox?
(usually
it would be just checkbox1.checked, but obvioulsy this does not work)

Thanks

Mike Fellows

Jul 13 '06 #3
Hi Mike,
Are the checkboxes the only controls in the panel? If so, then the
panels control collection would be 1-1 wth the checkboxes. ie CheckBox0 <=>
Me.Panel2.Controls(0). If not, why not keep a seperate collection of
references to the checkboxes you add and reference the correct one via the
index of the collection.
--
Terry
"Mike Fellows" wrote:
maybe you should read before posting

and atleast attempt to spell correctly

the checkbox names i gave where an example

and the for loop is fairly obvious, but again that was not my question!


<as********@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...

use a for loop
and before this name ur controls prperly.
Asad

Mike Fellows wrote:
I have created some checkboxes within a panel using the code below
Dim NewCheckbox As New CheckBox
Me.Panel2.Controls.Add(NewCheckbox)
NewCheckbox.Location = New Point(XLocation, YLocation)
NewCheckbox.AutoSize = True
NewCheckbox.Text = DS1.Tables(0).Rows(counter1)(0)
NewCheckbox.Name = "Checkbox" & counter1 + 1

the problem I have is how do i access the value of that checkbox?
(usually
it would be just checkbox1.checked, but obvioulsy this does not work)

Thanks

Mike Fellows


Jul 13 '06 #4
I think you are confusing the name of the checkbox and the reference to
the checkbox, you cannot just use the name of the checkbox to access
it's members as you suggest. Instead, you need the reference to the
checkbox.

So Asad was basically correct.

Dim cbx As checkbox
'Get a reference to the cbx named checkbox1 within panel1
For c as control in panel1.controls
If typeof(c) is checkbox then
cbx = c
If cbx.Name = "checkbox1" then
Exit For
Else
cbx = Nothing
End If
End If
Next

If Not cbx Is Nothing Then
If cbx.Checked then
'checkbox named checkbox1 is checked so do whatever here.
End if
End If

Andy

Mike Fellows wrote:
maybe you should read before posting

and atleast attempt to spell correctly

the checkbox names i gave where an example

and the for loop is fairly obvious, but again that was not my question!


<as********@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...

use a for loop
and before this name ur controls prperly.
Asad

Mike Fellows wrote:
I have created some checkboxes within a panel using the code below
Dim NewCheckbox As New CheckBox
Me.Panel2.Controls.Add(NewCheckbox)
NewCheckbox.Location = New Point(XLocation, YLocation)
NewCheckbox.AutoSize = True
NewCheckbox.Text = DS1.Tables(0).Rows(counter1)(0)
NewCheckbox.Name = "Checkbox" & counter1 + 1

the problem I have is how do i access the value of that checkbox?
(usually
it would be just checkbox1.checked, but obvioulsy this does not work)

Thanks

Mike Fellows
Jul 13 '06 #5
Thanks

I understood i couldnt just use.checked but wasnt sure how else to do it

Thanks

Mike Fellows
"CaffieneRush" <Ca**********@gmail.comwrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...
>I think you are confusing the name of the checkbox and the reference to
the checkbox, you cannot just use the name of the checkbox to access
it's members as you suggest. Instead, you need the reference to the
checkbox.

So Asad was basically correct.

Dim cbx As checkbox
'Get a reference to the cbx named checkbox1 within panel1
For c as control in panel1.controls
If typeof(c) is checkbox then
cbx = c
If cbx.Name = "checkbox1" then
Exit For
Else
cbx = Nothing
End If
End If
Next

If Not cbx Is Nothing Then
If cbx.Checked then
'checkbox named checkbox1 is checked so do whatever here.
End if
End If

Andy

Mike Fellows wrote:
>maybe you should read before posting

and atleast attempt to spell correctly

the checkbox names i gave where an example

and the for loop is fairly obvious, but again that was not my question!


<as********@gmail.comwrote in message
news:11**********************@m79g2000cwm.googleg roups.com...
>
use a for loop
and before this name ur controls prperly.
Asad

Mike Fellows wrote:
I have created some checkboxes within a panel using the code below
Dim NewCheckbox As New CheckBox
Me.Panel2.Controls.Add(NewCheckbox)
NewCheckbox.Location = New Point(XLocation, YLocation)
NewCheckbox.AutoSize = True
NewCheckbox.Text = DS1.Tables(0).Rows(counter1)(0)
NewCheckbox.Name = "Checkbox" & counter1 + 1

the problem I have is how do i access the value of that checkbox?
(usually
it would be just checkbox1.checked, but obvioulsy this does not work)

Thanks

Mike Fellows

Jul 14 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ondernemer | last post by:
Hi guys, On my page I dynamically create different checkboxes. <input type="checkbox" name="ch1" value="some value"> option 1 <input type="checkbox" name="ch2" value="some value"> option 2...
2
by: R Duke | last post by:
I have tried everything I can think of to change the visible property of a design time created control from a dynamically created control's command event handler. Here is the scenario. I have...
2
by: Suma | last post by:
I have a problem with editable datagrid and was hoping if anyone could help me. Please help me if possible. I have an editable datagrid, whose column count I don’t know until runtime. I am...
4
by: epigram | last post by:
I've got a page that has a Panel object that I am dynamically adding CheckBox controls to. The number of CheckBox controls and the name of each control is based on a database query. I would like...
3
by: Mike Fellows | last post by:
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....
12
by: vbnewbie | last post by:
I am having problems accessing properties of dynamically generated objects in VB2005. Can someone please help? In a nutshell: My app creates an equal number of checkboxes and labels that share the...
7
by: Srikanth Ram | last post by:
Hi, I'm creating a PHP application. In this a dynamic table with the fields in the database is generated in a page. I have placed a checkbox in each row of the table to approve/disapprove...
1
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
7
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.