Get selected checkbox list items : CheckBox List « GUI Windows Form « C# / C Sharp

C# / C Sharp
1. 2D Graphics
2. Class Interface
3. Collections Data Structure
4. Components
5. Data Types
6. Database ADO.net
7. Design Patterns
8. Development Class
9. Event
10. File Stream
11. Generics
12. GUI Windows Form
13. Language Basics
14. LINQ
15. Network
16. Office
17. Reflection
18. Regular Expressions
19. Security
20. Services Event
21. Thread
22. Web Services
23. Windows
24. XML
25. XML LINQ
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
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
C# / C Sharp » GUI Windows Form » CheckBox ListScreenshots 
Get selected checkbox list items
Get selected checkbox list items

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

public class Form1 : System.Windows.Forms.Form {
   private System.Windows.Forms.CheckedListBox chkListPossibleValues;
   private System.Windows.Forms.ListBox lstSelected;
   private System.Windows.Forms.Button btnMove;
   private System.ComponentModel.Container components=null;

   public Form1() {
      InitializeComponent();
      this.chkListPossibleValues.Items.Add("Ten");
   }

   private void InitializeComponent() {
      this.lstSelected = new System.Windows.Forms.ListBox();
      this.btnMove = new System.Windows.Forms.Button();
      this.chkListPossibleValues = new System.Windows.Forms.CheckedListBox();
      this.SuspendLayout();
  
      this.lstSelected.Location = new System.Drawing.Point(2328);
      this.lstSelected.Name = "lstSelected";
      this.lstSelected.Size = new System.Drawing.Size(136186);
      this.lstSelected.TabIndex = 1;

      this.btnMove.Location = new System.Drawing.Point(15280);
      this.btnMove.Name = "btnMove";
      this.btnMove.TabIndex = 3;
      this.btnMove.Text = "Move";
      this.btnMove.Click += new System.EventHandler(this.btnMove_Click);

      this.chkListPossibleValues.CheckOnClick = true;
      this.chkListPossibleValues.Items.AddRange(new object[] {"One""Two""Three",
                  "Four""Five","Six","Seven""Eight""Nine"});
      this.chkListPossibleValues.Location = new System.Drawing.Point(88);
      this.chkListPossibleValues.Name = "chkListPossibleValues";
      this.chkListPossibleValues.Size = new System.Drawing.Size(136184);
      this.chkListPossibleValues.TabIndex = 0;

      this.AutoScaleBaseSize = new System.Drawing.Size(513);
      this.ClientSize = new System.Drawing.Size(376205);
      this.Controls.AddRange(new System.Windows.Forms.Control[] {this.btnMove,
                                  this.lstSelected,  this.chkListPossibleValues});
      this.Name = "Form1";
      this.Text = "List Boxes";
      this.ResumeLayout(false);

      }

      static void Main() {
         Application.Run(new Form1());
      }

      private void btnMove_Click(object sender, System.EventArgs e) {
         if (this.chkListPossibleValues.CheckedItems.Count > 0) {
            this.lstSelected.Items.Clear();
            foreach (string item in this.chkListPossibleValues.CheckedItems) {
                this.lstSelected.Items.Add(item.ToString());
            }
            for (int i = 0; i < this.chkListPossibleValues.Items.Count; i++){
                 this.chkListPossibleValues.SetItemChecked(i, false);
            }     
         }
      }
}



           
       
Related examples in the same category
1. CheckedListBox Item Check eventCheckedListBox Item Check event
www.__j___ava_2__s__.___c___o__m___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.