On my form I have 10 checkboxes named chkbox1,chkbox2,....chkbox10. I would
have like to set it up as an array control like in VB6 where I could have
chkbox(1),chkbox(2) but I think .net you have to have specific names for
each control. All 10 of the boxes are in a groupbox. What I'm trying to do
is when I hit a button it will loop through all the checkboxes to see which
ones are checked and add that checkbox name to a string. Something like
Names = chkbox1.text & " " chkbox2.text & " " ect... Once I got a list of
all the ones that were checked all 10 would be reset and unchecked to start
over.
Thanks,
Tim 8 42001
"Tim" <dg******@maine.rrdotcom> scripsit: On my form I have 10 checkboxes named chkbox1,chkbox2,....chkbox10. I would have like to set it up as an array control like in VB6 where I could have chkbox(1),chkbox(2) but I think .net you have to have specific names for each control. All 10 of the boxes are in a groupbox. What I'm trying to do is when I hit a button it will loop through all the checkboxes to see which ones are checked and add that checkbox name to a string. Something like Names = chkbox1.text & " " chkbox2.text & " " ect... Once I got a list of all the ones that were checked all 10 would be reset and unchecked to start over.
Creating Control Arrays in Visual Basic .NET and Visual C# .NET
<http://msdn.microsoft.com/library/?url=/library/en-us/dv_vstechart/html/vbtchCreatingControlArraysInVisualBasicNETVisualCN ET.asp>
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
"Tim" <dg******@maine.rrdotcom> schrieb On my form I have 10 checkboxes named chkbox1,chkbox2,....chkbox10.
You can use expressive names instead of numbers.
I would have like to set it up as an array control like in VB6 where I could have chkbox(1),chkbox(2) but I think .net you have to have specific names for each control.
You don't have to, but you can.
All 10 of the boxes are in a groupbox. What I'm trying to do is when I hit a button it will loop through all the checkboxes to see which ones are checked and add that checkbox name to a string. Something like Names = chkbox1.text & " " chkbox2.text & " " ect... Once I got a list of all the ones that were checked all 10 would be reset and unchecked to start over.
You can still put the Checkboxes into an array:
Once (in constructor or in OnLoad):
Dim AllCheckboxes As CheckBox() = {chk1, chk2, chk3, ... chkbox10}
Later:
dim chk as checkbox
dim sb as new system.text.stringbuilder
dim names as string
for each chk in allcheckboxes
if chk.checked Then
sb.append(chk.text)
sb.append(" "c)
chk.check = false
end if
next chk
names = sb.tostring(0, sb.length - 1)
_Instead_ of the array (AllCheckboxes), you can loop through the controls in
the GroupBox:
dim chk as checkbox
for each chk in mygroupbox.controls
'same as above
next chk
If there are also other types of controls in the same groupbox:
dim o as object
for each o in mygroupbox.controls
if typeof o is checkbox then
dim chk as checkbox
chk = directcast(o, checkbox)
'same as above
end if
next chk
--
Armin
1) You could create an array that contains a reference to each of the
checkboxes. Just add them manually. Just because you can't have control
arrays alla VB6 doesn't mean you can't use arrays.
2) If the form has all of the checkboxes you are interested in, and you
don't expect to have more, you can loop through the controls collection of
the form (For each chk as Checkbox in me.controls)
3) You can add all the checkboxes to a panel and do the same as #2 but the
panel's controls. This gives you a little more extensibility.
I'm sure there are more ways.
"Tim" <dg******@maine.rrdotcom> wrote in message
news:T0*****************@twister.nyroc.rr.com... On my form I have 10 checkboxes named chkbox1,chkbox2,....chkbox10. I
would have like to set it up as an array control like in VB6 where I could have chkbox(1),chkbox(2) but I think .net you have to have specific names for each control. All 10 of the boxes are in a groupbox. What I'm trying to
do is when I hit a button it will loop through all the checkboxes to see
which ones are checked and add that checkbox name to a string. Something like Names = chkbox1.text & " " chkbox2.text & " " ect... Once I got a list of all the ones that were checked all 10 would be reset and unchecked to
start over.
Thanks,
Tim
Hi Tim, On my form I have 10 checkboxes named chkbox1,chkbox2,....chkbox10. I
would have like to set it up as an array control like in VB6 where I could have chkbox(1),chkbox(2) but I think .net you have to have specific names for each control. All 10 of the boxes are in a groupbox. What I'm trying to
do is when I hit a button it will loop through all the checkboxes to see
which ones are checked and add that checkbox name to a string. Something like Names = chkbox1.text & " " chkbox2.text & " " ect... Once I got a list of all the ones that were checked all 10 would be reset and unchecked to
start over.
Something like this I think.
\\\\
dim strb as system.text.stringbuilder
Dim ctr As Control
Dim a As New System.Text.StringBuilder
For Each ctr In Me.GroupBox1.Controls
Dim ctrchk As CheckBox = DirectCast(ctr, CheckBox)
If ctrchk.Checked Then
strb.Append(ctrchk.Name.ToString)
End If
Next
dim strEnd as string = strb.tostring
////
I hope this helps a little bit
Cor
Here is an article I submitted to PSC which may help you.
Matt http://www.planetsourcecode.com/vb/s...1376&lngWId=10
"Tim" <dg******@maine.rrdotcom> wrote in message
news:T0*****************@twister.nyroc.rr.com... On my form I have 10 checkboxes named chkbox1,chkbox2,....chkbox10. I
would have like to set it up as an array control like in VB6 where I could have chkbox(1),chkbox(2) but I think .net you have to have specific names for each control. All 10 of the boxes are in a groupbox. What I'm trying to
do is when I hit a button it will loop through all the checkboxes to see
which ones are checked and add that checkbox name to a string. Something like Names = chkbox1.text & " " chkbox2.text & " " ect... Once I got a list of all the ones that were checked all 10 would be reset and unchecked to
start over.
Thanks,
Tim
"Tim" <dg******@maine.rrdotcom> wrote in message news:<T0*****************@twister.nyroc.rr.com>... On my form I have 10 checkboxes named chkbox1,chkbox2,....chkbox10. I would have like to set it up as an array control like in VB6 where I could have chkbox(1),chkbox(2) but I think .net you have to have specific names for each control. All 10 of the boxes are in a groupbox. What I'm trying to do is when I hit a button it will loop through all the checkboxes to see which ones are checked and add that checkbox name to a string. Something like Names = chkbox1.text & " " chkbox2.text & " " ect... Once I got a list of all the ones that were checked all 10 would be reset and unchecked to start over.
Thanks,
Tim
Dim ctrl as Control
Dim ChkBx as CheckBox
For each ctrl in GroupBox.Controls
If ctrl.GetType is ChkBx.GetType Then
ctrl = DirectCast(ctl, CheckBox)
If ctrl.Checked Then
'do stuff
End If
End If
Next
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim c As System.Windows.Forms.CheckBox
For Each c In GroupBox1.Controls()
c.Checked = True
Next
end Sub
Armin Zingler wrote: "Tim" <dg******@maine.rrdotcom> schrieb On my form I have 10 checkboxes named chkbox1,chkbox2,....chkbox10.
You can use expressive names instead of numbers.
I would have like to set it up as an array control like in VB6 where I could have chkbox(1),chkbox(2) but I think .net you have to have specific names for each control.
You don't have to, but you can.
All 10 of the boxes are in a groupbox. What I'm trying to do is when I hit a button it will loop through all the checkboxes to see which ones are checked and add that checkbox name to a string. Something like Names = chkbox1.text & " " chkbox2.text & " " ect... Once I got a list of all the ones that were checked all 10 would be reset and unchecked to start over.
You can still put the Checkboxes into an array:
Once (in constructor or in OnLoad): Dim AllCheckboxes As CheckBox() = {chk1, chk2, chk3, ... chkbox10}
Later: dim chk as checkbox dim sb as new system.text.stringbuilder dim names as string
for each chk in allcheckboxes if chk.checked Then sb.append(chk.text) sb.append(" "c) chk.check = false end if next chk
names = sb.tostring(0, sb.length - 1)
_Instead_ of the array (AllCheckboxes), you can loop through the controls in the GroupBox:
dim chk as checkbox for each chk in mygroupbox.controls 'same as above next chk
If there are also other types of controls in the same groupbox: dim o as object for each o in mygroupbox.controls if typeof o is checkbox then dim chk as checkbox chk = directcast(o, checkbox) 'same as above end if next chk
"One Handed Man" <Bo****@Duck.net> schrieb Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim c As System.Windows.Forms.CheckBox
For Each c In GroupBox1.Controls()
c.Checked = True
Next
end Sub
I'm trying to figure out the difference. Ok, I accidently wrote "chk.check =
False" (not checkED) instead, but that's all I can see.
--
Armin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: jeffsnox |
last post by:
Hi,
I have multiple checkboxes on the same form as follows:
<input type='checkbox' name='cbtype' value='1'>
<input type='checkbox' name='cbtype' value='2'>
<input type='checkbox'...
|
by: ramapv |
last post by:
can i highlight a checkbox from a group of checkbox with particular name which is given as a search key.
I am having a list of checkboxes and i have to select some of them and form a group.but i'm...
|
by: favor08 |
last post by:
I have a continious subform that 9000 + records and I have serveral
check marks on the subform. so it ties to that record.
Does anyone have any examples were they use multiple checkboxes in a ...
|
by: dream2rule |
last post by:
Hello All,
I am trying to validate multiple checkboxes whose values are stored in an array using php. I have been trying from a really long time but nothing's working out.
Can anyone help?
...
|
by: serghei |
last post by:
I have already the insert form and the database. It's working to insert multiple data with multiple checkboxes. But I can't retrieve multiple data.
|
by: Ned Balzer |
last post by:
Hi,
Can anyone point me in the direction of a solution for validating
multiple checkboxes in an asp.net 2.0 page?
1) This is not a checkboxlist, it is a number of separate checkboxes
2) I do...
|
by: santoshjsh |
last post by:
hello everyone,
i have a gridview in which i have multiple checkboxes in a single column.
means for every row in the gridview i have four checkboxes in one column e.g Add, Delete, Print,...
|
by: raamay |
last post by:
hey experts, please advise me what is the best way to save multiple checkboxes value in a database. I have 6 checkboxes and i came across storing the values in a single column of a table which i dont...
|
by: kimmelsd33 |
last post by:
I am adding to my software. I have placed about 30 checkboxes on a form. Based on which checkboxes are selected, I want to print the values to a tab delimited text file. For instance, the first...
|
by: BabyLucifer666 |
last post by:
Hello All, (using Access2000)
I have a form with multiple unbound checkboxes. What I would like to do is have the user check whoever needs to take a specific training course. My database is...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |