473,466 Members | 1,397 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Controls function

I have three checkbox that I want to check the state (checkbox1
checkbox2 checkbox3

I do the following

Dim i As Integer
Dim chk As New CheckBox
For i = 1 To 3
chk = (Controls("CheckBox" & CStr(i)))
If chk.CheckState = CheckState.Unchecked Then
.....Code
End If
Next

This works if the checkbox are NOT in a Panel only. Why??

Feb 6 '07 #1
2 1041
<Ja***@aol.comschrieb
I have three checkbox that I want to check the state (checkbox1
checkbox2 checkbox3

I do the following

Dim i As Integer
Dim chk As New CheckBox
For i = 1 To 3
chk = (Controls("CheckBox" & CStr(i)))
If chk.CheckState = CheckState.Unchecked Then .....Code
End If
Next

This works if the checkbox are NOT in a Panel only. Why??
Because they are not controls in the Form but controls in the Panel. Use
this instead:

chk = YourPanel.Controls("CheckBox" & CStr(i))

Armin

Feb 6 '07 #2
On Feb 6, 5:59 am, "Armin Zingler" <az.nos...@freenet.dewrote:
<J...@aol.comschrieb
I have three checkbox that I want to check the state (checkbox1
checkbox2 checkbox3
I do the following
Dim i As Integer
Dim chk As New CheckBox
For i = 1 To 3
chk = (Controls("CheckBox" & CStr(i)))
If chk.CheckState = CheckState.Unchecked Then .....Code
End If
Next
This works if the checkbox are NOT in a Panel only. Why??

Because they are not controls in the Form but controls in the Panel. Use
this instead:

chk = YourPanel.Controls("CheckBox" & CStr(i))

Armin
Just adding to Armin. If the only checkboxes your panel contains are
the checkboxes you want to investigate you could do this (as I hate
getting controls by name):

<pseudocode>

For each ctl as Control in YourPanel.Controls
If typeof(ctl) is Checkbox andalso directcast(ctl,
Checkbox).CheckState = CheckState.Unchecked then
' Do Stuff
End If
Next

</pseudocode>

Thanks,

Seth Rowe
Feb 6 '07 #3

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

Similar topics

1
by: @ndy | last post by:
Hi developers, i've a problem with my tabcontrol. Before i open my form with a tabcontrol with 3 tabs (Frm_Files|Frm_Lines|Frm_Guarantee) all the controls on al the tabs must be enabled. With...
8
by: Invalidlastname | last post by:
Hi, We are developing an asp.net application, and we dynamically created certain literal controls to represent some read-only text for certain editable controls. However, recently we found an issue...
2
by: Osmosis | last post by:
I have a form with several controls, which all have their validating and validated events in my code. However, if these controls don't get focus, these events don't get called. When my OK...
7
by: Rich | last post by:
Hello, I have a form with 5 textboxes named txt0, txt1, txt2, txt3, tx4. In VB6 I could iterate through these with For i = 0 to 4 debug.print Me.controls("txt" & i).Name Next
15
by: Arpan | last post by:
Consider the following code which retrieves data from a SQL Server 2005 DB table & displays it in a DataGrid: <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)...
0
by: comp974 | last post by:
ok, here is the situation, I am trying to construct a table with several ASP.net 2.0 controls in it during execution time in an VB.net enviroment. For starters, I have a textbox and a linkbutton...
4
by: rn5a | last post by:
Assume that a ASPX page uses a user control named Address.ascx which has 2 TextBoxes. This ASCX page creates 2 properties named 'Address' & 'City' using the Get & Set statements: <script...
2
by: WolfyUK | last post by:
Hello, I have a standard asp:DataGrid called CasesGrid that I wish to write my own paging controls for. The aim is to get something like the following rendered to screen: << First < Previous...
3
by: Ken Fine | last post by:
I'm interested in programmatically manipulating groups of ASP.NET controls by type. Can someone suggest code for the following? Loop through, say, all label controls on a page, and assigning a...
3
by: Andreas Wöckl | last post by:
Hi Group! I have a web form that is created dynamically - so I create Textboxes, RadioButtonLists, CheckBoxLists and so on - I have found some articles that there may be some problems with...
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
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
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...
1
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...
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
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
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 ...

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.