Add items to combo box : CheckBox « GUI Windows Form « C# / C Sharp

C# / C Sharp
1. 2D Graphics
2. Collections Data Structure
3. Components
4. Database ADO.net
5. Development Class
6. Event
7. File Stream
8. GUI Windows Form
9. Language Basics
10. Network
11. Office
12. Regular Expressions
13. Services Event
14. Thread
15. Web Services
16. Windows
17. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
C# / C Sharp » GUI Windows Form » CheckBoxScreenshots 
Add items to combo box
Add items to combo box


using System;
using System.Drawing;
using System.Windows.Forms;
public class Select : Form {
  private Button draw = new Button();
  private ComboBox color = new ComboBox();

  public Select( ) {
    draw.Text = "Draw";
    color.Text = "Choose a color";
    Size = new Size(500,250);

    int w = 20;
    draw.Location = new Point(20,30);
    color.Location = new Point(w += 10 + color.Width, 30);

    color.Items.Add("Red");
    color.Items.Add("Green");
    color.Items.Add("Blue");

    Controls.Add(draw);
    Controls.Add(color);

    draw.Click += new EventHandler(Draw_Click);
  

  protected void Draw_Click(Object sender, EventArgs e) {
    if (color.SelectedItem.ToString() == "Red" )
      Console.WriteLine("It is red.");
    else if (color.SelectedItem.ToString() == "Green")
      Console.WriteLine("It is green.");
    else
      Console.WriteLine("It is blue.");
  }
  static void Main() {
    Application.Run(new Select());
  }
}
           
       
Related examples in the same category
1. Is CheckBox checkedIs CheckBox checked
2. CheckBox click (Selected/Unselected) eventCheckBox click (Selected/Unselected) event
3. Get Selected item from ComboBoxGet Selected item from ComboBox
4. ComboBox Selected Item changed event
5. CheckButton on a FormCheckButton on a Form
6. CheckBox StyleCheckBox Style
w___w__w_._j__a_v__a2s_.__c__o___m | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.