You are on page 1of 2

BBA-040 Software Engineering Lecture 8

Chapter 8
Windows Form Application (Codes)

Shown the names of months regarding their numbers.


{
string[] k = { "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December" };
textBox2.Text = k[listBox2.SelectedIndex];
}

Or with other way

{
if (listBox2.SelectedIndex == 0)
textBox2.Text = "January";
else if (listBox2.SelectedIndex == 1)
textBox2.Text = "February";
else if (listBox2.SelectedIndex == 2)
textBox2.Text = "March";
else if (listBox2.SelectedIndex == 3)
textBox2.Text = "April";
else if (listBox2.SelectedIndex == 4)
textBox2.Text = "May";
else if (listBox2.SelectedIndex == 5)
textBox2.Text = "June";
else if (listBox2.SelectedIndex == 6)
textBox2.Text = "July";
else if (listBox2.SelectedIndex == 7)
textBox2.Text = "August";
else if (listBox2.SelectedIndex == 8)
textBox2.Text = "September";
else if (listBox2.SelectedIndex == 9)
textBox2.Text = "October";
else if (listBox2.SelectedIndex == 10)
textBox2.Text = "November";
else
textBox2.Text = "December";
}
BBA-040 Software Engineering Lecture 8

From Textbox to Listbox tool.


{
if (textBox3.Text == "")
MessageBox.Show("Enter any name");
else
{
listBox3.Items.Add(textBox3.Text);
textBox3.Text = "";
}
}

Clear function
{
textBox1.Clear();
label1.Text = "";
listBox1.Items.Clear();
}

You might also like