public static void UncheckAllItems(this System.Windows.Forms.CheckedListBox clb)
 {
     while (clb.CheckedIndices.Count > 0)
     {
         clb.SetItemChecked(clb.CheckedIndices[0], false);
     }
 }
Exemple #2
0
        static void CheckedListBox_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            System.Windows.Forms.CheckedListBox lCheck = (System.Windows.Forms.CheckedListBox)sender;

            if (lCheck.SelectedItem.ToString().Equals("Selecionar Todos") && lCheck.GetItemChecked(0))
            {
                for (int i = 0; i < ((System.Windows.Forms.CheckedListBox)sender).Items.Count; i++)
                {
                    lCheck.SetItemChecked(i, true);

                    if (!lCheck.SelectedItem.ToString().Equals("Selecionar Todos"))
                    {
                        gListaClienteSelecionadosFiltro.Add((int)(lCheck.Items[i]));
                    }
                }
            }
            else if (lCheck.SelectedItem.ToString().Equals("Selecionar Todos") && !lCheck.GetItemChecked(0))
            {
                for (int i = 0; i < ((System.Windows.Forms.CheckedListBox)sender).Items.Count; i++)
                {
                    lCheck.SetItemChecked(i, false);

                    if (!lCheck.SelectedItem.ToString().Equals("Selecionar Todos"))
                    {
                        gListaClienteSelecionadosFiltro.Remove((int)(lCheck.Items[i]));
                    }
                }
            }
            else
            {
                if (!lCheck.SelectedItem.ToString().Equals("Selecionar Todos"))
                {
                    int lConta = Convert.ToInt32(lCheck.SelectedItem);

                    if (gListaClienteSelecionadosFiltro.Contains(lConta))
                    {
                        gListaClienteSelecionadosFiltro.Remove(lConta);
                    }
                    else
                    {
                        gListaClienteSelecionadosFiltro.Add(lConta);
                    }
                }
            }
        }
Exemple #3
0
        public static void SetItemsChecked(System.Windows.Forms.CheckedListBox checkedlistbox, bool check)
        {
            if (checkedlistbox == null)
            {
                throw new System.ArgumentNullException("checkedlistbox");
            }

            foreach (int index in System.Linq.Enumerable.Range(0, checkedlistbox.Items.Count))
            {
                checkedlistbox.SetItemChecked(index, check);
            }
        }
 public void BuildPicker(ref System.Windows.Forms.CheckedListBox clb)
 {
     clb.BeginUpdate();
     clb.Items.Clear();
     clb.Items.Add("<No category assigned>");
     foreach (String catName in getNames())
     {
         clb.Items.Add(catName);
     }
     foreach (String cat in Settings.Instance.Categories)
     {
         try {
             clb.SetItemChecked(clb.Items.IndexOf(cat), true);
         } catch { /* Category "cat" no longer exists */ }
     }
     clb.EndUpdate();
 }