Sunday, 20 January 2013

CheckedListBox in c#.net

 private void frmItemGeneral_Load(object sender, EventArgs e)
        {
 checkedListBox1.DataSource = objitemgeneral.GetItemData1(obj);
            checkedListBox1.DisplayMember = "Text";
            checkedListBox1.ValueMember = "Value";
       }
 private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e )
      {
         string item =
checkedListBox1.SelectedItem.ToString();

         if e.NewValue == CheckState.Checked )
           
checkedListBox2.Items.Additem );
         else
           
checkedListBox1.Items.Removeitem );
      }

private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (i = 0; i < checkedListBox1.Items.Count; i++)
                if (checkedListBox1.GetItemChecked(i) == true)
                {
                    MessageBox.Show(checkedListBox1.GetItemText(i).ToString());
                 
                }
        } 


 TAGGING_Item obj2 = new TAGGING_Item();
        private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            List<TAGGING_Item> obj1 = new List<TAGGING_Item>();
            for (i = 0; i < checkedListBox1.Items.Count; i++)
            {
                if (checkedListBox1.GetItemChecked(i) == true)
                {
                    obj2 = ((TAGGING_Item)checkedListBox1.Items[i]);
                    obj1.Add(obj2);
                }
            }
        }

No comments:

Post a Comment