RadioButton Control
A radio button or option button enables the user to select a single option from a
group of choices when paired with other RadioButton controls. When a user clicks
on a radio button, it becomes checked, and all other radio buttons with same group
become unchecked
Add the following to above design
First step:
private void Form1_Load(object sender, EventArgs e)
{
[Link] = false;
[Link] = false;
[Link] = false;
}
Second step:
private void redrbtn_CheckedChanged(object sender, EventArgs
e)
{
if ([Link] == true)
{
[Link] = true;
[Link] = false;
[Link] = false;
}
}
Third step:
private void bluerbtn_CheckedChanged(object sender, EventArgs
e)
{
if([Link] == true )
{
[Link] = true;
[Link] = false;
[Link] = false;
}
}
Fourth step:
private void greenrbtn_CheckedChanged(object sender, EventArgs
e)
{
if ([Link] ==true )
{
[Link] = true;
[Link] = false;
[Link] = false ;
}
}
----------------------------------------------------------------------------------------------------
ListBox Control
The ListBox control is the simplest of the list-based controls and serves primarily to
display a
simple list of items in an easy-to-navigate user interface from which users can
select one or
more items.
First step:
The following code stepwise illustrate above design
Second step: write the following code under form load event
private void Form1_Load(object sender, EventArgs e)
{
[Link]("Sunday");
[Link]("Monday");
[Link]("Tuesday");
[Link]("Wednesday");
[Link]("Thursday");
[Link]("Friday");
Step no-3:
private void addbtn_Click(object sender, EventArgs e)
{
// preventing List Box from duplicate data
string str = [Link];
bool duplicate = false;
foreach (object obj in [Link])
{
if ([Link]() == str)
{
duplicate = true;
break;
}
}
if (duplicate)
{
[Link]("name already exist");
}
else if ([Link] != "")
{
[Link]([Link]);
[Link]();
[Link]();
}
Step no-4:
private void removebtn_Click(object sender, EventArgs e)
{
[Link]([Link]);
Step no-5:
private void showbtn_Click(object sender, EventArgs e)
{
// This code is used to select multi index
[Link] = [Link] ;
//this code is used to display SelectedItems through
message box
foreach (object obj in [Link])
{
[Link]([Link]());
}
}
Step no-6:
private void loadlistbtn_Click(object sender, EventArgs e)
{
List<string> strlist = new List<string>();
[Link]("ali");
[Link]("raza");
[Link]("ajmal");
[Link] = strlist;
//List<string> intlist = new List<string>();
//[Link](0, "Irfan");
//[Link](1, "Rashid");
//[Link](2, "Usman");
//[Link] = intlist;
}
-------------------------------------------------------------------------------------------------------------------------------