473,500 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic controls

Joe
quick question,
Im using VB.NET
Im creating a checkbox dynamically then I stick it on a panel. I give each
one a unique id example: "chkLONDON"
Dim oObjCheckBox As CheckBox = New CheckBox()

oObjCheckBox.ID = "chk" +
CType(dsCustomer.Tables(0).Rows(iCount).Item("LocN ame"), String)

oObjCheckBox.Text = CType(dsCustomer.Tables(0).Rows(iCount).Item("LocN ame"),
String)

pnlLocs.Controls.Add(oObjCheckBox)

My problem now is, how do I see if that value is checked or not from my
code. When I push my submit button I want to check if its cheked or not. I
tried the following but it didn't work.

Dim oObjCheckBox As CheckBox = New CheckBox()

oObjCheckBox.ID = "chkLONDON"

If (oObjCheckBox.Checked) Then

'do some stuff

Else

Nov 21 '05 #1
4 2087
Hello Joe,

To use the dynamically created controls you have to get the reference of the
control object.
Here you can do that by iterating through the controls in Panel.

Dim myControl as Control
For each myControl in Panel.Controls
If TypeOf (myControl) Is CheckBox Then
Dim myCheckBox as CheckBox
If myCheckBox.ID="Test" and myCheckBox. myCheckBox.Checked then
'Do your stuff
Exit For
End If
End If
Next

Hopes this will help

Sakharam Phapale
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.com...
quick question,
Im using VB.NET
Im creating a checkbox dynamically then I stick it on a panel. I give each one a unique id example: "chkLONDON"
Dim oObjCheckBox As CheckBox = New CheckBox()

oObjCheckBox.ID = "chk" +
CType(dsCustomer.Tables(0).Rows(iCount).Item("LocN ame"), String)

oObjCheckBox.Text = CType(dsCustomer.Tables(0).Rows(iCount).Item("LocN ame"), String)

pnlLocs.Controls.Add(oObjCheckBox)

My problem now is, how do I see if that value is checked or not from my
code. When I push my submit button I want to check if its cheked or not. I tried the following but it didn't work.

Dim oObjCheckBox As CheckBox = New CheckBox()

oObjCheckBox.ID = "chkLONDON"

If (oObjCheckBox.Checked) Then

'do some stuff

Else

Nov 21 '05 #2
Hi Joe,

I missed one statement so corrected here.

Dim myControl as Control
For each myControl in Panel.Controls
If TypeOf (myControl) Is CheckBox Then
Dim myCheckBox as CheckBox

------------ myCheckBox =
Type(myControl,CheckBox) -----------------------------------

If myCheckBox.ID="Test" and myCheckBox. myCheckBox.Checked then
'Do your stuff
Exit For
End If
End If
Next
"Sakharam Phapale" <sp******@annetsite.com> wrote in message
news:OJ*************@TK2MSFTNGP10.phx.gbl...
Hello Joe,

To use the dynamically created controls you have to get the reference of the control object.
Here you can do that by iterating through the controls in Panel.

Dim myControl as Control
For each myControl in Panel.Controls
If TypeOf (myControl) Is CheckBox Then
Dim myCheckBox as CheckBox

myCheckBox = CType(myControl,CheckBox)

If myCheckBox.ID="Test" and myCheckBox. myCheckBox.Checked then
'Do your stuff
Exit For
End If
End If
Next

Hopes this will help

Sakharam Phapale
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.com...
quick question,
Im using VB.NET
Im creating a checkbox dynamically then I stick it on a panel. I give each
one a unique id example: "chkLONDON"
Dim oObjCheckBox As CheckBox = New CheckBox()

oObjCheckBox.ID = "chk" +
CType(dsCustomer.Tables(0).Rows(iCount).Item("LocN ame"), String)

oObjCheckBox.Text =

CType(dsCustomer.Tables(0).Rows(iCount).Item("LocN ame"),
String)

pnlLocs.Controls.Add(oObjCheckBox)

My problem now is, how do I see if that value is checked or not from my
code. When I push my submit button I want to check if its cheked or

not. I
tried the following but it didn't work.

Dim oObjCheckBox As CheckBox = New CheckBox()

oObjCheckBox.ID = "chkLONDON"

If (oObjCheckBox.Checked) Then

'do some stuff

Else


Nov 21 '05 #3
Hello Joe,

To use the dynamically created controls you have to get the reference of the
control object.
Here you can do that by iterating through the controls in Panel.

Dim myControl as Control
For each myControl in Panel.Controls
If TypeOf (myControl) Is CheckBox Then
Dim myCheckBox as CheckBox
If myCheckBox.ID="Test" and myCheckBox. myCheckBox.Checked then
'Do your stuff
Exit For
End If
End If
Next

Hopes this will help

Sakharam Phapale
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.com...
quick question,
Im using VB.NET
Im creating a checkbox dynamically then I stick it on a panel. I give each one a unique id example: "chkLONDON"
Dim oObjCheckBox As CheckBox = New CheckBox()

oObjCheckBox.ID = "chk" +
CType(dsCustomer.Tables(0).Rows(iCount).Item("LocN ame"), String)

oObjCheckBox.Text = CType(dsCustomer.Tables(0).Rows(iCount).Item("LocN ame"), String)

pnlLocs.Controls.Add(oObjCheckBox)

My problem now is, how do I see if that value is checked or not from my
code. When I push my submit button I want to check if its cheked or not. I tried the following but it didn't work.

Dim oObjCheckBox As CheckBox = New CheckBox()

oObjCheckBox.ID = "chkLONDON"

If (oObjCheckBox.Checked) Then

'do some stuff

Else

Nov 21 '05 #4
Hi Joe,

I missed one statement so corrected here.

Dim myControl as Control
For each myControl in Panel.Controls
If TypeOf (myControl) Is CheckBox Then
Dim myCheckBox as CheckBox

------------ myCheckBox =
Type(myControl,CheckBox) -----------------------------------

If myCheckBox.ID="Test" and myCheckBox. myCheckBox.Checked then
'Do your stuff
Exit For
End If
End If
Next
"Sakharam Phapale" <sp******@annetsite.com> wrote in message
news:OJ*************@TK2MSFTNGP10.phx.gbl...
Hello Joe,

To use the dynamically created controls you have to get the reference of the control object.
Here you can do that by iterating through the controls in Panel.

Dim myControl as Control
For each myControl in Panel.Controls
If TypeOf (myControl) Is CheckBox Then
Dim myCheckBox as CheckBox

myCheckBox = CType(myControl,CheckBox)

If myCheckBox.ID="Test" and myCheckBox. myCheckBox.Checked then
'Do your stuff
Exit For
End If
End If
Next

Hopes this will help

Sakharam Phapale
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.com...
quick question,
Im using VB.NET
Im creating a checkbox dynamically then I stick it on a panel. I give each
one a unique id example: "chkLONDON"
Dim oObjCheckBox As CheckBox = New CheckBox()

oObjCheckBox.ID = "chk" +
CType(dsCustomer.Tables(0).Rows(iCount).Item("LocN ame"), String)

oObjCheckBox.Text =

CType(dsCustomer.Tables(0).Rows(iCount).Item("LocN ame"),
String)

pnlLocs.Controls.Add(oObjCheckBox)

My problem now is, how do I see if that value is checked or not from my
code. When I push my submit button I want to check if its cheked or

not. I
tried the following but it didn't work.

Dim oObjCheckBox As CheckBox = New CheckBox()

oObjCheckBox.ID = "chkLONDON"

If (oObjCheckBox.Checked) Then

'do some stuff

Else


Nov 21 '05 #5

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

Similar topics

1
6307
by: Will | last post by:
Hi all. I'm learning VB.Net and am developing a WinForms app. I'm trying to make an app that I will use to scan in one or more than on image. I want to use a tabbed interface to hold each image....
2
5294
by: theComputer7 | last post by:
I cut down the code to make this half way understandable... I have read Data Grid girls caution about over use of dynamic controls. I truly believe what I am doing requires dynamically inserted...
3
3945
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
0
1327
by: pbb | last post by:
I have a web page on which I dynamically create controls based on the selection a user makes from a dropdownlist (this ddl is not dynamic). Depending on the user's selection, the controls could be...
1
2169
by: Diffident | last post by:
Hello All, I am trying to add dynamic controls onto my page and here is how I am doing that. I have a page which has a button called as "AddMoreControls" and in this button's event handler I...
9
3606
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have...
0
5269
by: Eniac | last post by:
Hi, I've been working on a custom user control that needs to be modified and the validation is causing me headaches. The control used to generate a table of 4 rows x 7 columns to display all...
1
4635
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
3465
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
2
5004
by: englishman69 | last post by:
Hello, I have been banging my head against this one for a while... Searches online have revealed many different proposals for correcting my issue but none that I can follow! My basic situation...
0
7136
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
7018
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
7182
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5490
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
4611
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...
0
3110
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1430
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 ...
0
316
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...

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.