469,288 Members | 2,357 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,288 developers. It's quick & easy.

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 7743
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by PawelR | last post: by
1 post views Thread by jez123456 | last post: by
8 posts views Thread by johnmmcparland | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.