473,761 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Contr ols.Add(NewChec kbox)
NewCheckbox.Loc ation = New Point(XLocation , YLocation)
NewCheckbox.Aut oSize = True
NewCheckbox.Tex t = DS1.Tables(0).R ows(counter1)(0 )
NewCheckbox.Nam e = "Checkbox" & counter1 + 1

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

Thanks

Mike Fellows
Jul 13 '06 #1
5 8398

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.Contr ols.Add(NewChec kbox)
NewCheckbox.Loc ation = New Point(XLocation , YLocation)
NewCheckbox.Aut oSize = True
NewCheckbox.Tex t = DS1.Tables(0).R ows(counter1)(0 )
NewCheckbox.Nam e = "Checkbox" & counter1 + 1

the problem I have is how do i access the value of that checkbox? (usually
it would be just checkbox1.check ed, 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********@gma il.comwrote in message
news:11******** **************@ m79g2000cwm.goo glegroups.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.Cont rols.Add(NewChe ckbox)
NewCheckbox.Lo cation = New Point(XLocation , YLocation)
NewCheckbox.Au toSize = True
NewCheckbox.Te xt = DS1.Tables(0).R ows(counter1)(0 )
NewCheckbox.Na me = "Checkbox" & counter1 + 1

the problem I have is how do i access the value of that checkbox?
(usually
it would be just checkbox1.check ed, 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.Contr ols(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********@gma il.comwrote in message
news:11******** **************@ m79g2000cwm.goo glegroups.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.Contr ols.Add(NewChec kbox)
NewCheckbox.Loc ation = New Point(XLocation , YLocation)
NewCheckbox.Aut oSize = True
NewCheckbox.Tex t = DS1.Tables(0).R ows(counter1)(0 )
NewCheckbox.Nam e = "Checkbox" & counter1 + 1

the problem I have is how do i access the value of that checkbox?
(usually
it would be just checkbox1.check ed, 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********@gma il.comwrote in message
news:11******** **************@ m79g2000cwm.goo glegroups.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.Contr ols.Add(NewChec kbox)
NewCheckbox.Loc ation = New Point(XLocation , YLocation)
NewCheckbox.Aut oSize = True
NewCheckbox.Tex t = DS1.Tables(0).R ows(counter1)(0 )
NewCheckbox.Nam e = "Checkbox" & counter1 + 1

the problem I have is how do i access the value of that checkbox?
(usually
it would be just checkbox1.check ed, 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
"CaffieneRu sh" <Ca**********@g mail.comwrote in message
news:11******** *************@m 73g2000cwd.goog legroups.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********@gm ail.comwrote in message
news:11******* *************** @m79g2000cwm.go oglegroups.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.Cont rols.Add(NewChe ckbox)
NewCheckbox.Lo cation = New Point(XLocation , YLocation)
NewCheckbox.Au toSize = True
NewCheckbox.Te xt = DS1.Tables(0).R ows(counter1)(0 )
NewCheckbox.Na me = "Checkbox" & counter1 + 1

the problem I have is how do i access the value of that checkbox?
(usually
it would be just checkbox1.check ed, 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
2015
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 <input type="checkbox" name="ch3" value="some value"> option 3 <input type="checkbox" name="ch4" value="some value"> option 4 The reason they have different names is because of a different script which
2
2928
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 a WebForm with some textboxes, dropdownlists, a panel, imagebutton and so on. When I click on the image button (which was created at design time) I dynamically build a table. In each of row of that new table I put several cells and one cell...
2
1434
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 sure of 3 columns Id,Name and Description. But there also might be more. So I add these 3 columns and an editcommandbutton and deletecommnadbutton at design time. Then during runtime I insert my other columns that I need, in between
4
2407
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 to know how I can query for all the CheckBox controls on the page during postback and check their checked attribute without using the name of each checkbox. I want to do this in a generic way so that I don't have to requery the db or save the...
3
1092
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. change its state) currently im doing the following: While count < DS4.Tables(0).Rows.Count
12
13274
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 same Tag number. (I thought it might help) The checkboxes name is a concatenation of "chkCancel" and a number that represents the order in which they were created: chkCancel0 (Tag = 0) chkCancel1 (Tag = 1)
7
2545
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 according to spec. This checkbox is also created dynamically according to the fields in the database. Now I need to place a checkbox/ button (by checking the checkbox all the checkbox in the page has to be checked). I checked online and I was able to find...
1
4911
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 set text boxes and labels inside the table rows. I then added a button. All of these are done through code. The problem that i am having is i can get the value from a text box with resides inside the first panel (out side of panel that is...
7
6669
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 tabcontainer which has 1 panel already, however I want to try create the TabPanels dynamically. I followed the advice here: http://www.asp.net/learn/ajax-videos/video-156.aspx (3rd comment - Joe Stagner)
0
9554
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9989
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9925
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7358
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3913
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.