Working with RadioButtons in Windows Forms

by Jagadish Pulakhandam on 4/11/2011 4:56:45 PM
Rated 0 from 0 votes
Brief: This sample demonstrates RadioButton control in Windows Forms using C#.
Posted to: Microsoft Windows Forms - RadioButton
Add to DiggAdd to del.icio.usAdd to FURLAdd to RedditAdd to YahooAdd to BlinklistAdd to GoogleAdd to ma.gnoliaAdd to ShadowsAdd to Technorati

This sample demonstrates on how to use RadioButtons in Windows Forms.  "Checked" is the main property (of RadioButton control) which returns boolean value based on its selected status.

Following is the screen shot:



Following is the code:

01.using System;
02.using System.Collections.Generic;
03.using System.ComponentModel;
04.using System.Data;
05.using System.Drawing;
06.using System.Linq;
07.using System.Text;
08.using System.Windows.Forms;
09. 
10.namespace WinFormsRadioButtonsDemo
11.{
12.    public partial class Form1 : Form
13.    {
14.        public Form1()
15.        {
16.            InitializeComponent();
17.        }
18.         
19.        private void rbFgRed_CheckedChanged(object sender, EventArgs e)
20.        {
21.            this.textBox1.ForeColor = Color.Red;
22.        }
23. 
24.        private void rbFgGreen_CheckedChanged(object sender, EventArgs e)
25.        {
26.            this.textBox1.ForeColor = Color.Green;
27.        }
28. 
29.        private void rbFgBlue_CheckedChanged(object sender, EventArgs e)
30.        {
31.            this.textBox1.ForeColor = Color.Blue;
32.        }
33. 
34.        private void rbBgRed_CheckedChanged(object sender, EventArgs e)
35.        {
36.            this.textBox1.BackColor  = Color.Red;
37.        }
38. 
39.        private void rbBgGreen_CheckedChanged(object sender, EventArgs e)
40.        {
41.            this.textBox1.BackColor = Color.Green;
42.        }
43. 
44.        private void rbBgBlue_CheckedChanged(object sender, EventArgs e)
45.        {
46.            this.textBox1.BackColor = Color.Blue;
47.        }
48. 
49.    }
50.}

Join the .NET Code Central Community and join the discussion!
Signing-up is FREE and quick. Do it now, we want to hear your opinion
0

Rated 0 from 0 votes ( login  to rate)
DotnetKicks DotnetKicksDe DotNetShoutout

Attachments / Source Code
You need to Login or Join for FREE to download the following