Simplified radiobutton code in VB.net

Source: Internet
Author: User
Simplify the following code
Private sub radiobutton1_checkedchanged (byval sender as system. Object, byval e as system. eventargs) handles radiobutton1.checkedchanged
Kind = "Focus"
End sub
Private sub radiobutton2_checkedchanged (byval sender as system. Object, byval e as system. eventargs) handles radiobutton2.checkedchanged
Kind = "news"
End sub

....................

End sub
Private sub radiobutton15_checkedchanged (byval sender as system. Object, byval e as system. eventargs) handles radiobutton2.checkedchanged
Kind = "study"
End sub
Private sub radiobutton16_checkedchanged (byval sender as system. Object, byval e as system. eventargs) handles radiobutton2.checkedchanged
Kind = "culture"
End sub

1. ASP. NET can use radiobuttonlist
Select case radiobuttonlist1.selecteditem. Value
Case 1
Kind = "Sports"
Case 2

......

End select
2. radiobuttonlist seems to be available only in ASP. NET.
You can use addhandler to handle these events to a function, and then use sender is radiobutton1.
?

Private sub radiobutton1_click (byval sender as system. Object, byval e as system. eventargs) handles radiobutton1.click, radiobutton2.click ,...
Kind = ctype (sender, radiobutton). text' set the text of radiobutton to the desired text
End sub

It is better to use the click event. When the checkedchange event is used, it is also triggered when its checked is changed from true to false. It seems a little different from what you mean, or you need to judge in the Code:
If ctype (sender, radiobutton). Checked then
...
End if

Http://community.csdn.net/Expert/TopicView3.asp? Id = 3774477

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.