473,387 Members | 1,664 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,387 software developers and data experts.

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 2085
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
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
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
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
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
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
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
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
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
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
2
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...

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.