ARTICLE

RadioButton Control in VB.NET

Posted by Shalini Juneja Articles | Windows Controls March 15, 2011
In this Article we will demonstrate on RadioButton. its class hierarchy,event with one RadioButton Example.
Download Files:
 
Reader Level:

The RadioButton control is used to display a Radio Button.RadioButton control allow users to select from a small set of mutually-exclusive, pre-defined choices. The controls allow you to define any number of radio buttons with labels and to arrange them horizontally or vertically.We can select only One RadioButton at a time.it is similar to CheckBox but RadioButtons are displayed as rounded instead of box.

The class hierarchy for this control is as follows:

  • Object
  • Control
  • Webcontrol
  • CheckBox
  • Radiobutton

Radiobutton Event

The default event of the RadioButton is the CheckedChanged event

RadioButton Sample

Drag two radio button's, a textbox and Two button on to the form. Select each radio button and set the GroupName property for each to ABC. If you do not set the GroupName property to a common name then each radio button will act differently and when you make a selection all radio buttons will be rounded. In most cases, you want your users to select only one option from a given list and to accompolish that you need to set the GroupName property. 

The form will look like bolow when we drag all the controls

Then we put this code on the double click of the submit button and reset button

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If
RadioButton1.Checked Then
 
TextBox1.Text = "You Clicked" & " " & RadioButton1.Text()
ElseIf
RadioButton2.Checked Then
 
TextBox1.Text = "Your Clicked" & " " & RadioButton2.Text()
End
If
 End
Sub
Private
Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
 TextBox1.Text = ""
End Sub
 End Class

Output:

 

Login to add your contents and source code to this article
share this article :
post comment
 

it's a good explanation. up up ?

Posted by Russel Vasquez Mar 15, 2011
Nevron Diagram
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Team Foundation Server Hosting
Become a Sponsor