0% found this document useful (0 votes)
12 views12 pages

Visual Programming: Duhok Private Technical Institute

Uploaded by

duhokbarwary33
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views12 pages

Visual Programming: Duhok Private Technical Institute

Uploaded by

duhokbarwary33
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Duhok Private Technical Institute

VISUAL
PROGRAMMING
( VISUAL C# )

Lecturer Ashraf

Lecture 3 1
Windows Programming
Using C#
Forms Programming I

✓ ComboBox
✓ CheckedBox
✓ CheckedListBox

2
ComboBox
• 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.
Without Code:
1- Right-click on combobox
2- Properties
3- Items
4- Enter the strings one per line
5- Ok
By Code: Inserting
items to
combobox

private void button1_Click(object sender, EventArgs e)


{ comboBox1.Items.Add(“one”);
comboBox1.Items.Add(“Two”);

}
Remove
items from
combobox

private void button2_Click(object sender, EventArgs e)


{ comboBox1.Items.RemoveAt(comboBox1.SelectedIndex); }
By Code with textbox: Inserting
items to
combobox

private void button1_Click(object sender, EventArgs e)


{ comboBox1.Items.Add(textBox1.Text); }
Remove
items from
combobox

private void button2_Click(object sender, EventArgs e)


{ comboBox1.Items.RemoveAt(comboBox1.SelectedIndex); }
ListBox

• 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 Buttons—through the Button Click
event handler.
CheckedListBox
• CheckedListBox presents several items in a list. Each
item is checkable—the user can check a box. The
CheckedListBox control in Windows Forms is a way to
make longer, dynamic checkable lists.
Adding & delete items
From:
• ListBox
• ComboBox
• CheckedListBox
Example
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();
}

You might also like