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

Groupbox with radiobutton

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 not,
if Me.rb1stbutton.checked than .. store 0
if Me.rb2..... checked then store 1
.........
if Me.rb6... checked then store 5.

Any other simple method to know which button is checked ? thanks a lot
Nov 21 '05 #1
8 7958
Note a handler can handle more than one event, you can determine the
sender's name within the handler. The example here handler all three boxes.
Alternatively you can have a handler for each

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles RadioButton1.CheckedChanged,
RadioButton2.CheckedChanged, RadioButton3.CheckedChanged

End Sub

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
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 not,
if Me.rb1stbutton.checked than .. store 0
if Me.rb2..... checked then store 1
........
if Me.rb6... checked then store 5.

Any other simple method to know which button is checked ? thanks a lot

Nov 21 '05 #2
I know handler can handler many event. but my question,
How can I know which button does the user click ??

"Microsoft" <me@me.com> 在郵件 news:eE**************@TK2MSFTNGP10.phx.gbl 中
撰寫...
Note a handler can handle more than one event, you can determine the
sender's name within the handler. The example here handler all three boxes. Alternatively you can have a handler for each

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged,
RadioButton2.CheckedChanged, RadioButton3.CheckedChanged

End Sub

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
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 not,
if Me.rb1stbutton.checked than .. store 0
if Me.rb2..... checked then store 1
........
if Me.rb6... checked then store 5.

Any other simple method to know which button is checked ? thanks a lot


Nov 21 '05 #3
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles RadioButton1.CheckedChanged,
RadioButton2.CheckedChanged, RadioButton3.CheckedChanged

Dim rb As RadioButton

rb = DirectCast(sender, RadioButton)

Select Case rb.Name

Case Me.RadioButton1.Name

'Ur Action

Case Me.RadioButton2.Name

'Ur Action

Case Me.RadioButton3.Name

'Ur Action

End Select

End Sub

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:e6**************@TK2MSFTNGP09.phx.gbl...
I know handler can handler many event. but my question,
How can I know which button does the user click ??

"Microsoft" <me@me.com> 在郵件 news:eE**************@TK2MSFTNGP10.phx.gbl 中 撰寫...
Note a handler can handle more than one event, you can determine the
sender's name within the handler. The example here handler all three

boxes.
Alternatively you can have a handler for each

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object,

ByVal
e As System.EventArgs) Handles RadioButton1.CheckedChanged,
RadioButton2.CheckedChanged, RadioButton3.CheckedChanged

End Sub

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
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 not,
if Me.rb1stbutton.checked than .. store 0
if Me.rb2..... checked then store 1
........
if Me.rb6... checked then store 5.

Any other simple method to know which button is checked ? thanks a lot



Nov 21 '05 #4
On Fri, 29 Oct 2004 12:27:39 +0100, Microsoft wrote:
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles RadioButton1.CheckedChanged,
RadioButton2.CheckedChanged, RadioButton3.CheckedChanged

Dim rb As RadioButton

rb = DirectCast(sender, RadioButton)

Select Case rb.Name


Rather than use a Select Case, store the associated value in the
RadioButton's Tag property Then you can use a single line in your
CheckChanged Handler:

Private Sub RadioButton_CheckedChanged(...) Handles rb1.CheckChanged,..,...
Dim x As Integer = CInt(DirectCast(sender,RadioButton).Tag)
End Sub

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Nov 21 '05 #5
Thats an interesting and quite clever solution to her problem Chris.

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--
"Chris Dunaway" <"dunawayc[[at]_lunchmeat_sbcglobal[dot]]net"> wrote in
message news:gb******************************@40tude.net.. .
On Fri, 29 Oct 2004 12:27:39 +0100, Microsoft wrote:
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object,
ByVal
e As System.EventArgs) Handles RadioButton1.CheckedChanged,
RadioButton2.CheckedChanged, RadioButton3.CheckedChanged

Dim rb As RadioButton

rb = DirectCast(sender, RadioButton)

Select Case rb.Name


Rather than use a Select Case, store the associated value in the
RadioButton's Tag property Then you can use a single line in your
CheckChanged Handler:

Private Sub RadioButton_CheckedChanged(...) Handles
rb1.CheckChanged,..,...
Dim x As Integer = CInt(DirectCast(sender,RadioButton).Tag)
End Sub

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.

Nov 21 '05 #6
Actually, a little variation here to avert the problems of a double fire.

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles RadioButton1.CheckedChanged,
RadioButton2.CheckedChanged, RadioButton3.CheckedChanged

Static lastChanged As Int32

Dim rb As RadioButton = DirectCast(sender, RadioButton)

Dim tag As Int32 = CType(rb.Tag, Int32)

If lastChanged <> tag Then

Debug.WriteLine(tag.ToString)

End If

lastChanged = tag

End Sub
--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:uC**************@TK2MSFTNGP11.phx.gbl...
Thats an interesting and quite clever solution to her problem Chris.

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--
"Chris Dunaway" <"dunawayc[[at]_lunchmeat_sbcglobal[dot]]net"> wrote in
message news:gb******************************@40tude.net.. .
On Fri, 29 Oct 2004 12:27:39 +0100, Microsoft wrote:
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object,
ByVal
e As System.EventArgs) Handles RadioButton1.CheckedChanged,
RadioButton2.CheckedChanged, RadioButton3.CheckedChanged

Dim rb As RadioButton

rb = DirectCast(sender, RadioButton)

Select Case rb.Name


Rather than use a Select Case, store the associated value in the
RadioButton's Tag property Then you can use a single line in your
CheckChanged Handler:

Private Sub RadioButton_CheckedChanged(...) Handles
rb1.CheckChanged,..,...
Dim x As Integer = CInt(DirectCast(sender,RadioButton).Tag)
End Sub

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.


Nov 21 '05 #7
OH, Thanks for all your kind help
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> 在郵件
news:Ob**************@TK2MSFTNGP15.phx.gbl 中撰寫...
Actually, a little variation here to avert the problems of a double fire.

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged,
RadioButton2.CheckedChanged, RadioButton3.CheckedChanged

Static lastChanged As Int32

Dim rb As RadioButton = DirectCast(sender, RadioButton)

Dim tag As Int32 = CType(rb.Tag, Int32)

If lastChanged <> tag Then

Debug.WriteLine(tag.ToString)

End If

lastChanged = tag

End Sub
--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:uC**************@TK2MSFTNGP11.phx.gbl...
Thats an interesting and quite clever solution to her problem Chris.

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--
"Chris Dunaway" <"dunawayc[[at]_lunchmeat_sbcglobal[dot]]net"> wrote in
message news:gb******************************@40tude.net.. .
On Fri, 29 Oct 2004 12:27:39 +0100, Microsoft wrote:

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object,
ByVal
e As System.EventArgs) Handles RadioButton1.CheckedChanged,
RadioButton2.CheckedChanged, RadioButton3.CheckedChanged

Dim rb As RadioButton

rb = DirectCast(sender, RadioButton)

Select Case rb.Name
Rather than use a Select Case, store the associated value in the
RadioButton's Tag property Then you can use a single line in your
CheckChanged Handler:

Private Sub RadioButton_CheckedChanged(...) Handles
rb1.CheckChanged,..,...
Dim x As Integer = CInt(DirectCast(sender,RadioButton).Tag)
End Sub

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.



Nov 21 '05 #8
On Fri, 29 Oct 2004 15:42:03 +0100, One Handed Man ( OHM - Terry Burns )
wrote:
Actually, a little variation here to avert the problems of a double fire.


Perhaps a little simpler is to just check the checked property. Since
radiobutton's are mutually exclusive within the same group, only one will
be checked so you could do this to avoid a multiple fire:

Private Sub RadioButton_CheckedChanged(...) Handles rb1.CheckChanged,..,...
If DirectCast(sender,RadioButton).Checked Then
Dim x As Integer = CInt(DirectCast(sender,RadioButton).Tag)
End If
End Sub

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Nov 21 '05 #9

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

Similar topics

0
by: PawelR | last post by:
Hello Group, I've problem with get number of Items in groupBox. I've in my apps groupBox with over 20 radioButton. 1. How read who radioButton is checked? 2. How run function after change...
1
by: jez123456 | last post by:
Hi I have a Windows GroupBox (m_groupBox) on a form which acts as a filter and contains 26 filter radiobuttons (m_radioButtonA through m_radioButtonZ). How can I check in code which...
4
by: Ricky W. Hunt | last post by:
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...
8
by: johnmmcparland | last post by:
Hi all, my program is trying to add group boxes with radio buttons at run time. While at one point it was able to draw the group boxes without the radio buttons, now it encounters problems just...
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...
0
by: Rich | last post by:
Hello, I have a form that contains some textboxes and a couple of groupboxes that contain some radiobuttons. I have set the tabstop to false for all the radiobuttions. When the form originally...
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...
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...
4
by: Gugale at Lincoln | last post by:
Hi, I am using reflection to read names from enum and creating radio buttons inside a groupbox. Everything is working fine. However, I am not able to adjust the size of the group box to fit the...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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.