際際滷

際際滷Share a Scribd company logo
Vp lecture 4 ararat
 ComboBox is a combination TextBox with a drop-
down. Its drop-down list presents preset choices. The
user can type anything into the ComboBox.
Alternatively, he or she can select something from the
list.
Vp lecture 4 ararat
private void button1_Click(object sender, EventArgs e)
{
if (comboBox1.SelectedItem.ToString() == "two")
MessageBox.Show( comboBox1.SelectedItem.ToString());
}
private void button1_Click(object sender, EventArgs e)
{ comboBox1.Items.Add(textBox3.Text); }
private void button2_Click(object sender, EventArgs e)
{ comboBox1.Items.RemoveAt(comboBox1.SelectedIndex); }
Inserting
items to
combobox
Remove
items from
combobox
 ListBox stores several text items. It can interact with
other controls, including Button controls. We use this
control in Windows Forms. In the example program it
interacts with two Buttonsthrough the Button Click
event handler.
 CheckedListBox presents several items in a list. Each
item is checkablethe user can check a box. The
CheckedListBox control in Windows Forms is a way to
make longer, dynamic checkable lists.
From:
 ListBox
 ComboBox
 CheckedListBox
Vp lecture 4 ararat
private void button1_Click(object sender, EventArgs e)
{ checkedListBox1.Items.Add(textBox1.Text); }
private void button2_Click(object sender, EventArgs e)
{ checkedListBox1.Items.RemoveAt(checkedListBox1.SelectedIndex); }
private void button5_Click(object sender, EventArgs e)
{ comboBox1.Items.Add(textBox3.Text); }
private void button6_Click(object sender, EventArgs e)
{ comboBox1.Items.RemoveAt(comboBox1.SelectedIndex); }
private void button3_Click(object sender, EventArgs e)
{ listBox1.Items.Add(textBox2.Text); }
private void button4_Click(object sender, EventArgs e)
{ listBox1.Items.RemoveAt(listBox1.SelectedIndex); }
private void button8_Click(object sender, EventArgs e)
{
MessageBox.Show(checkedListBox1.SelectedItem.ToString()+'n'+
comboBox1.SelectedItem.ToString() + 'n' +
listBox1.SelectedItem.ToString());
}
private void button7_Click(object sender, EventArgs e)
{
Application.Exit();
}
Vp lecture 4 ararat

More Related Content

Vp lecture 4 ararat

  • 2. ComboBox is a combination TextBox with a drop- down. Its drop-down list presents preset choices. The user can type anything into the ComboBox. Alternatively, he or she can select something from the list.
  • 4. private void button1_Click(object sender, EventArgs e) { if (comboBox1.SelectedItem.ToString() == "two") MessageBox.Show( comboBox1.SelectedItem.ToString()); }
  • 5. private void button1_Click(object sender, EventArgs e) { comboBox1.Items.Add(textBox3.Text); } private void button2_Click(object sender, EventArgs e) { comboBox1.Items.RemoveAt(comboBox1.SelectedIndex); } Inserting items to combobox Remove items from combobox
  • 6. ListBox stores several text items. It can interact with other controls, including Button controls. We use this control in Windows Forms. In the example program it interacts with two Buttonsthrough the Button Click event handler.
  • 7. CheckedListBox presents several items in a list. Each item is checkablethe user can check a box. The CheckedListBox control in Windows Forms is a way to make longer, dynamic checkable lists.
  • 8. From: ListBox ComboBox CheckedListBox
  • 10. private void button1_Click(object sender, EventArgs e) { checkedListBox1.Items.Add(textBox1.Text); } private void button2_Click(object sender, EventArgs e) { checkedListBox1.Items.RemoveAt(checkedListBox1.SelectedIndex); } private void button5_Click(object sender, EventArgs e) { comboBox1.Items.Add(textBox3.Text); } private void button6_Click(object sender, EventArgs e) { comboBox1.Items.RemoveAt(comboBox1.SelectedIndex); } private void button3_Click(object sender, EventArgs e) { listBox1.Items.Add(textBox2.Text); } private void button4_Click(object sender, EventArgs e) { listBox1.Items.RemoveAt(listBox1.SelectedIndex); }
  • 11. private void button8_Click(object sender, EventArgs e) { MessageBox.Show(checkedListBox1.SelectedItem.ToString()+'n'+ comboBox1.SelectedItem.ToString() + 'n' + listBox1.SelectedItem.ToString()); } private void button7_Click(object sender, EventArgs e) { Application.Exit(); }