473,405 Members | 2,279 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,405 software developers and data experts.

Determining which radiobutton within a Groupbox

Is there an easy, flexible way to determine which radiobutton is checked
within a groupbox without having to code for each button explicitly? It
seems there would be some kind of index you could use but I can't find
anything in the VS help or on MSDN online.

Something like:

(pseudocode)

If grpBox1.item(3).checked then

or

Select Case grpBox1.Item
Case 1....
Also, if there is an index, and you have more than one row/column of
buttons, how are they numbered?
I also want to make sure they have checked a button within the group
(meaning it starts out with no radiobuttons checked; i.e. I don't want there
to be a "default"). Is there a way to make sure a radiobutton within the
group is checked without having to ask about each radiobutton explicitly?

--
Thanks,
Ricky W. Hunt
freendeed
Nov 20 '05 #1
4 1749

"Ricky W. Hunt" <rh*****@hotmail.com> wrote in message
news:gpALc.157185$Oq2.11358@attbi_s52...
Is there an easy, flexible way to determine which radiobutton is checked
within a groupbox without having to code for each button explicitly? It
seems there would be some kind of index you could use but I can't find
anything in the VS help or on MSDN online.


No, there is nothing like this. Many people put code behind the buttons to
set a private variable, but there is simply nothing built-in to do this for
you.
Nov 20 '05 #2
"Jeff Johnson [MVP: VB]" <i.***@enough.spam> wrote in message
news:uG**************@TK2MSFTNGP09.phx.gbl...

"Ricky W. Hunt" <rh*****@hotmail.com> wrote in message
news:gpALc.157185$Oq2.11358@attbi_s52...
Is there an easy, flexible way to determine which radiobutton is checked
within a groupbox without having to code for each button explicitly? It
seems there would be some kind of index you could use but I can't find
anything in the VS help or on MSDN online.
No, there is nothing like this. Many people put code behind the buttons to
set a private variable, but there is simply nothing built-in to do this

for you.


Thanks.
Nov 20 '05 #3
Ricky,

Yes you can.

Beneath is an sample of my with checkboxes, it is alreaydy again old so
maybe there can be someting optimezed.

You can drag this on a new project and start to see it working. You can as
well create the technique by setting the radiobuttons using the designer
which needs a little different technique in creating the radiobutton array,
however try this first.

I hope this helps?

Cor

Private myCheckbox(10) As CheckBox
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
' makes 10 checkboxes
' you need for this to drag a button on a form
Dim start As Integer = 4
Dim top As Integer = 18
Dim i As Integer
For i = 1 To 10
myCheckbox(i) = New CheckBox
myCheckbox(i).TextAlign = ContentAlignment.MiddleCenter
myCheckbox(i).Width = 40
myCheckbox(i).Height = 20
myCheckbox(i).Location = New System.Drawing.Point(start, top)
myCheckbox(i).Text = i.ToString
myCheckbox(i).Cursor = Cursors.Hand
Me.Controls.Add(myCheckbox(i))
AddHandler myCheckbox(i).Click, AddressOf myCheckBox_Click
start = start + 40
If i = 5 Then
top = top + 20
start = 4
End If
Next
End Sub
Private Sub myCheckBox_Click _
(ByVal sender As Object, ByVal e As System.EventArgs)
Dim chk As CheckBox = DirectCast(sender, CheckBox)
MessageBox.Show(chk.Text)
End Sub
Private Sub Button1_Click _
(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Button1.Click
Dim ctr As Control
Dim a As New System.Text.StringBuilder
a.Remove(0, a.Length)
Dim i As Integer
For i = 1 To 10
If myCheckbox(i).Checked Then
a.Append(i.ToString)
End If
Next
MessageBox.Show(a.ToString)
End Sub

I hope this helps a little bit?

Cor
Nov 20 '05 #4
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OM**************@TK2MSFTNGP12.phx.gbl...
Ricky,

Yes you can.

Beneath is an sample of my with checkboxes, it is alreaydy again old so
maybe there can be someting optimezed.

You can drag this on a new project and start to see it working. You can as
well create the technique by setting the radiobuttons using the designer
which needs a little different technique in creating the radiobutton array, however try this first.

I hope this helps?


Got it. Thanks.
Nov 20 '05 #5

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

Similar topics

8
by: peter hansen | last post by:
.... in VB6 it was possible to import a RadioButton which had a property called GroupName. The GroupName prevented other RadioButtons to be in the group if they didn't had the same GroupName. ...
8
by: Agnes | last post by:
I create an array to store the radiobutton list. If the user click the 3rd buttons, I should store the value 2 into the table fields, My method is check each radio button whether is checked or...
3
by: LCAdeveloper | last post by:
Help! A trawl through the archives couldn't shed any light on this, so is there a way to handle DoubleClick events for RadioButtons in vb.NET? I'm recoding a VB4 application, which used the...
2
by: Rich | last post by:
Hello, I have a groupbox that contains 3 radiobuttons. Is there a groupbox property or some syntax that identifies which radiobutton is checked? Or do I have to loop? For Each rad As...
2
by: Rich | last post by:
Hello, Is it possible to assign a value to a groupbox by selecting a radiobutton contained in the groupbox? Say you assign a value of 1 to radbtn1, 2 for radbtn2, 3 for radbtn3 all contained...
4
by: Igor | last post by:
RadioButton have property Checked (true or false). If I make RadioButtons with code, without drawing by mouse than I have problems. I write like this: Dim rb(0 To 2) As RadioButton Dim n As...
2
by: =?Utf-8?B?UmljaA==?= | last post by:
Hello, GroupBox1 contains 3 radiobuttons. Is there a builtin way - a Container property - in the groupbox control to determine which radiobutton is checked - if any? I did not see anything...
5
by: Matt B | last post by:
I know this is a bit of nonstandard behavior, but I would like the Enter key to move focus through a group of radiobuttons without selecting them. The user would then have to use Space or actually...
8
by: =?Utf-8?B?UmljaA==?= | last post by:
If you enclose a group of radiobuttons (option buttons in MS Access) in an option group control (a frame control) in Access -- the frame control will return the index of the option button that is...
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
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...
0
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
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...

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.