SlideShare a Scribd company logo
1 of 12
• 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.
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 Buttons—through the Button Click
event handler.
• 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.
From:
• ListBox
• ComboBox
• CheckedListBox
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();
}
How to add and remove items from ComboBox, ListBox and CheckedListBox in C

More Related Content

What's hot

Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2Marlon Luz
 
Windows form application - C# Training
Windows form application - C# Training Windows form application - C# Training
Windows form application - C# Training Moutasm Tamimi
 
06 win forms
06 win forms06 win forms
06 win formsmrjw
 
4.7.14&17.7.14&23.6.15&10.9.15
4.7.14&17.7.14&23.6.15&10.9.154.7.14&17.7.14&23.6.15&10.9.15
4.7.14&17.7.14&23.6.15&10.9.15Rajes Wari
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMSaraswathiRamalingam
 
Federico landinez docx
Federico landinez docxFederico landinez docx
Federico landinez docxgabo2200
 
Guevara rene if then., else
Guevara rene  if then., elseGuevara rene  if then., else
Guevara rene if then., elsegabo2200
 
Christian rodriguez then else
Christian rodriguez then   elseChristian rodriguez then   else
Christian rodriguez then elsegabo2200
 
Federico landinez docx
Federico landinez docxFederico landinez docx
Federico landinez docxgabo2200
 
Parra maxi IF THEN ELSE
Parra maxi IF THEN ELSEParra maxi IF THEN ELSE
Parra maxi IF THEN ELSEgabo2200
 
Session 1. Bai 1 ve winform
Session 1. Bai 1 ve winformSession 1. Bai 1 ve winform
Session 1. Bai 1 ve winformmrtom16071980
 
Image contro, and format functions in vb
Image contro, and format functions in vbImage contro, and format functions in vb
Image contro, and format functions in vbAmandeep Kaur
 
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAMPROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAMSaraswathiRamalingam
 

What's hot (20)

Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2
 
Vp lecture 4 ararat
Vp lecture 4 araratVp lecture 4 ararat
Vp lecture 4 ararat
 
Windowforms controls c#
Windowforms controls c#Windowforms controls c#
Windowforms controls c#
 
Vs c# lecture4
Vs c# lecture4Vs c# lecture4
Vs c# lecture4
 
Windows form application - C# Training
Windows form application - C# Training Windows form application - C# Training
Windows form application - C# Training
 
06 win forms
06 win forms06 win forms
06 win forms
 
4.7.14&17.7.14&23.6.15&10.9.15
4.7.14&17.7.14&23.6.15&10.9.154.7.14&17.7.14&23.6.15&10.9.15
4.7.14&17.7.14&23.6.15&10.9.15
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
 
Federico landinez docx
Federico landinez docxFederico landinez docx
Federico landinez docx
 
Guevara rene if then., else
Guevara rene  if then., elseGuevara rene  if then., else
Guevara rene if then., else
 
Christian rodriguez then else
Christian rodriguez then   elseChristian rodriguez then   else
Christian rodriguez then else
 
Federico landinez docx
Federico landinez docxFederico landinez docx
Federico landinez docx
 
Parra maxi IF THEN ELSE
Parra maxi IF THEN ELSEParra maxi IF THEN ELSE
Parra maxi IF THEN ELSE
 
Vs c# lecture8
Vs c# lecture8Vs c# lecture8
Vs c# lecture8
 
Session 1. Bai 1 ve winform
Session 1. Bai 1 ve winformSession 1. Bai 1 ve winform
Session 1. Bai 1 ve winform
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
 
Active x control
Active x controlActive x control
Active x control
 
Image contro, and format functions in vb
Image contro, and format functions in vbImage contro, and format functions in vb
Image contro, and format functions in vb
 
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAMPROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
 
Java awt
Java awtJava awt
Java awt
 

Similar to How to add and remove items from ComboBox, ListBox and CheckedListBox in C

Similar to How to add and remove items from ComboBox, ListBox and CheckedListBox in C (17)

Latihan visual basic 2010/Looping/Perulangan
Latihan visual basic 2010/Looping/PerulanganLatihan visual basic 2010/Looping/Perulangan
Latihan visual basic 2010/Looping/Perulangan
 
Correction s+ rie_vb
Correction s+ rie_vbCorrection s+ rie_vb
Correction s+ rie_vb
 
.net progrmming part4
.net progrmming part4.net progrmming part4
.net progrmming part4
 
Colegio municipal
Colegio municipalColegio municipal
Colegio municipal
 
Calculator code
Calculator codeCalculator code
Calculator code
 
Ejercicio de Visual Basic IF THEN ELSE
Ejercicio de Visual Basic IF THEN ELSEEjercicio de Visual Basic IF THEN ELSE
Ejercicio de Visual Basic IF THEN ELSE
 
Federico landinez docx
Federico landinez docxFederico landinez docx
Federico landinez docx
 
Inventory management
Inventory managementInventory management
Inventory management
 
Listbox+checkedlistbox
Listbox+checkedlistboxListbox+checkedlistbox
Listbox+checkedlistbox
 
Código Editor Net
Código Editor NetCódigo Editor Net
Código Editor Net
 
Combo box
Combo boxCombo box
Combo box
 
vdocument.in_vb-combobox.ppt
vdocument.in_vb-combobox.pptvdocument.in_vb-combobox.ppt
vdocument.in_vb-combobox.ppt
 
Vb6 ch.7-3 cci
Vb6 ch.7-3 cciVb6 ch.7-3 cci
Vb6 ch.7-3 cci
 
Combo box
Combo boxCombo box
Combo box
 
Calculadora
CalculadoraCalculadora
Calculadora
 
Maliram poonia project
Maliram poonia projectMaliram poonia project
Maliram poonia project
 
Vs c# lecture9
Vs c# lecture9Vs c# lecture9
Vs c# lecture9
 

More from Saman M. Almufti (20)

Lecture 7- domain name
Lecture  7- domain nameLecture  7- domain name
Lecture 7- domain name
 
Vp lecture 11 ararat
Vp lecture 11 araratVp lecture 11 ararat
Vp lecture 11 ararat
 
Vp lecture 10 ararat
Vp lecture 10 araratVp lecture 10 ararat
Vp lecture 10 ararat
 
Vp lecture 12 ararat
Vp lecture 12 araratVp lecture 12 ararat
Vp lecture 12 ararat
 
Vp lecture 9 ararat
Vp lecture 9 araratVp lecture 9 ararat
Vp lecture 9 ararat
 
Lecture 6- http
Lecture  6- httpLecture  6- http
Lecture 6- http
 
Lecture 5- url-dns
Lecture  5- url-dnsLecture  5- url-dns
Lecture 5- url-dns
 
Vp lecture 7 ararat
Vp lecture 7 araratVp lecture 7 ararat
Vp lecture 7 ararat
 
Lecture 4- ip
Lecture  4- ipLecture  4- ip
Lecture 4- ip
 
Vp lecture 5 ararat
Vp lecture 5 araratVp lecture 5 ararat
Vp lecture 5 ararat
 
Lecture 3- tcp-ip
Lecture  3- tcp-ipLecture  3- tcp-ip
Lecture 3- tcp-ip
 
Vp lecture 3 ararat
Vp lecture 3 araratVp lecture 3 ararat
Vp lecture 3 ararat
 
Lecture 2- terminology
Lecture  2- terminologyLecture  2- terminology
Lecture 2- terminology
 
Vp lecture 2 ararat
Vp lecture 2 araratVp lecture 2 ararat
Vp lecture 2 ararat
 
Vp lecture1 ararat
Vp lecture1 araratVp lecture1 ararat
Vp lecture1 ararat
 
Lecture 1- introduction
Lecture  1- introductionLecture  1- introduction
Lecture 1- introduction
 
Vs c# lecture12
Vs c# lecture12Vs c# lecture12
Vs c# lecture12
 
Vs c# lecture11
Vs c# lecture11Vs c# lecture11
Vs c# lecture11
 
Vs c# lecture10
Vs c# lecture10Vs c# lecture10
Vs c# lecture10
 
Vs c# lecture7
Vs c# lecture7Vs c# lecture7
Vs c# lecture7
 

Recently uploaded

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Recently uploaded (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

How to add and remove items from ComboBox, ListBox and CheckedListBox in C

  • 1.
  • 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.
  • 3.
  • 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 Buttons—through the Button Click event handler.
  • 7. • 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.
  • 9.
  • 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(); }