6 Aralık 2013 Cuma

filling checkedListBox value member and text

  Filling checkedListBox
       
            List<CheckBoxItems> listCboxItems = new List<CheckBoxItems>();

            CheckBoxItems item = new CheckBoxItems();

            item.dataId = 1;
            item.Name = "evren";
            item.IsChecked = false;
            listCboxItems.Add(item);

            item = new CheckBoxItems();
            item.dataId = 2;
            item.Name = "ali";
            item.IsChecked = false;
            listCboxItems.Add(item);

           
            ((ListBox)this.checkedListBox1).DataSource = listCboxItems;
            ((ListBox)this.checkedListBox1).DisplayMember = "Name";
            ((ListBox)this.checkedListBox1).ValueMember = "dataId";

          for (int i = 0; i < checkedListBox1.Items.Count; i++)
            {
                CheckBoxItems obj = (CheckBoxItems)checkedListBox1.Items[i];
                checkedListBox1.SetItemChecked(i, obj.IsChecked);
            }

  Find out checked items

           foreach (CheckBoxItems item in checkedListBox1.CheckedItems)
            {
                string itemchecked = item.Name;
                MessageBox.Show(itemchecked); 
            }




 checkedListBox listItems class

    public class CheckBoxItems
    {
        public  bool IsChecked { get; set; }
        public  string Name { get; set; }
        public  int dataId { get; set; }
        public CheckBoxItems(){
           this.IsChecked = false;
        }

    }


evren pehlivan

http://www.tmrservisi.com/

filling checkedListBox value member and text, setting checkedListBox value member and text, populating checkedListBox value member and text, filling checkedListBox Items

evren pehlivan yazılım

evren pehlivan yazılım, evren pehlivan yazılım geliştirici