示例#1
0
 void deselectAllButton_Click(object sender, EventArgs e)
 {
     foreach (Control control in splitContainer1.Panel2.Controls)
     {
         if (control.GetType() == typeof(CheckedListBox))
         {
             CheckedListBox checkedlistBox = (CheckedListBox)control;
             for (int i = 1; i < checkedlistBox.Items.Count; i++)
                 checkedlistBox.SetItemCheckState(i, CheckState.Unchecked);
         }
     }
 }
示例#2
0
        private void Font_color_box_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            CheckedListBox this_obj = sender as CheckedListBox;

            foreach (int nIndex in this_obj.CheckedIndices)
            {
                if (nIndex != e.Index)
                {
                    this_obj.SetItemCheckState(nIndex, CheckState.Unchecked);
                }
            }
        }
 public static void limpiar(Control form)
 {
     foreach (Control control in form.Controls)
     {
         if (control is TextBox)
         {
             TextBox textBox = (TextBox)control;
             if (textBox.Enabled)
             {
                 textBox.Text = null;
             }
         }
         if (control is ComboBox)
         {
             ComboBox comboBox = (ComboBox)control;
             if (comboBox.Items.Count > 0)
             {
                 comboBox.SelectedIndex = -1;
             }
         }
         if (control is CheckBox)
         {
             CheckBox checkBox = (CheckBox)control;
             if (checkBox.ThreeState)
             {
                 checkBox.CheckState = CheckState.Indeterminate;
             }
             else
             {
                 checkBox.Checked = false;
             }
         }
         if (control is ListBox)
         {
             ListBox listBox = (ListBox)control;
             listBox.ClearSelected();
         }
         if (control is DateTimePicker)
         {
             DateTimePicker dateTimePicker = (DateTimePicker)control;
             dateTimePicker.Value = DateTime.Now;
         }
         if (control is CheckedListBox)
         {
             CheckedListBox checkedListBox = (CheckedListBox)control;
             foreach (int i in checkedListBox.CheckedIndices)
             {
                 checkedListBox.SetItemCheckState(i, CheckState.Unchecked);
             }
         }
     }
 }
示例#4
0
 // ----------------------------------------------------------------------------------------
 /// <!-- Toggle -->
 /// <summary>
 ///      Toggles the particular checked item specified
 /// </summary>
 /// <param name="clb"></param>
 /// <param name="idx"></param>
 public static void Toggle(Form form, CheckedListBox clb, int idx)
 {
     if (Scrape.Active(form, clb))
     {
         //if (_.InRange(-1, idx, clb.Items.Count))
         if (-1 < idx && idx <= clb.Items.Count)
         {
             if (clb.GetItemCheckState(idx) == CheckState.Checked)
             {
                 clb.SetItemCheckState(idx, CheckState.Unchecked);
             }
             else
             {
                 clb.SetItemCheckState(idx, CheckState.Checked);
             }
         }
         else
         {
             Pause();
         }
     }
 }
示例#5
0
        public void HasValidInput_ReturnsTrue_ForCheckedListBoxWithOneCheckedItem()
        {
            CheckedListBox listBox = new CheckedListBox();

            listBox.Items.Add("Item1");
            listBox.Items.Add("Item2");
            listBox.Items.Add("Item3");
            listBox.SetItemCheckState(0, CheckState.Checked);

            this._controls.Add(listBox);

            Assert.IsTrue(this._verifier.HasValidInput(this._controls), "HasValidInput returned false for checklistbox with a checked item.");
        }
            public int Add(object item, CheckState check)
            {
                //validate the enum that's passed in here
                //
                // Valid values are 0-2 inclusive.
                SourceGenerated.EnumValidator.Validate(check, nameof(check));

                int index = base.Add(item);

                _owner.SetItemCheckState(index, check);

                return(index);
            }
示例#7
0
        private void SortCheckBoxList(CheckedListBox chbl)
        {
            var checkedItems = chbl.CheckedItems.Cast <string>().ToArray();
            var sortedItems  = chbl.Items.Cast <string>().OrderBy(s => s).ToArray();

            chbl.Items.Clear();
            chbl.Items.AddRange(sortedItems);

            foreach (var ci in checkedItems)
            {
                chbl.SetItemCheckState(chbl.Items.IndexOf(ci), CheckState.Checked);
            }
        }
示例#8
0
        public static void CheckExistingMembersInCLB(Form forma, CheckedListBox list, Tim tim)
        {
            var items = list.Items;

            for (int i = 0; i < items.Count; i++)
            {
                int id   = ((Osoblje)items[i]).OsobljeID;
                var find = tim.ClanoviTima.Find(clan => clan.OsobljeID == id);
                if (find != null)
                {
                    forma?.Invoke(new Action(() => {
                        list.SetItemCheckState(i, CheckState.Checked);
                    }));
                }
                else
                {
                    forma?.Invoke(new Action(() => {
                        list.SetItemCheckState(i, CheckState.Unchecked);
                    }));
                }
            }
        }
示例#9
0
        private static void SetCheckState(CheckedListBox clb, string value, CheckState state)
        {
            int index = 0;

            foreach (object item in clb.Items)
            {
                if (item.ToString() == value)
                {
                    clb.SetItemCheckState(index, state);
                    return;
                }
                index++;
            }
        }
示例#10
0
        /// <summary>
        /// Called when [list box item check].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.ItemCheckEventArgs"/> instance containing the event data.</param>
        void OnListBoxItemCheck(object sender, ItemCheckEventArgs e)
        {
            CheckedListBox clst = (CheckedListBox)sender;

            // if default is checked, uncheck the rest
            if (clst.Items[e.Index].GetType() == typeof(String) && e.NewValue == CheckState.Checked)
            {
                for (int x = e.Index + 1; x < clst.Items.Count; x++)
                {
                    clst.SetItemCheckState(x, CheckState.Unchecked);
                }
                frmsvr.CloseDropDown();
            }
        }
示例#11
0
 //when we click next data or prev data we need to clear every checked data in the list and
 //we need to check appropriate datas
 private void ClearCheckedDataFromCheckedListBox(CheckedListBox _chcLstLabels)
 {
     //item check fires everytime we check or uncheck the object so we need to stop doing it while clearing data
     //otherwise we will loose datas
     UnregisterItemCheckEvent(chcLstLabels_ItemCheck);
     for (int j = 0; j < _chcLstLabels.Items.Count; j++)
     {
         if (_chcLstLabels.GetItemCheckState(j) == CheckState.Checked)
         {
             _chcLstLabels.SetItemCheckState(j, CheckState.Unchecked);
         }
     }
     RegisterItemCheckEvent(chcLstLabels_ItemCheck);
 }
示例#12
0
 private void f_set_check(CheckedListBox v_c, bool v_b)
 {
     try
     {
         for (int i = 0; i < v_c.Items.Count; i++)
         {
             v_c.SetItemChecked(i, v_b);
             v_c.SetItemCheckState(i, v_b?CheckState.Checked:CheckState.Unchecked);
         }
     }
     catch
     {
     }
 }
示例#13
0
        public void OnCheckedListBoxKeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if ((e.KeyCode == Keys.A) && e.Control)
            {
                e.Handled = true;

                CheckedListBox list = sender as CheckedListBox;

                for (int i = 0; i < list.Items.Count; i++)
                {
                    list.SetItemCheckState(i, CheckState.Checked);
                }
            }
        }
        private void cmbStudenti_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            broj           = 0;
            lblPoruka.Text = "";
            cmbStudenti.ResetText();
            svi_predmeti_studenta.Items.Clear();

            //checklistbox kreiranje
            svi_predmeti_studenta.Size     = new Size(400, 200);
            svi_predmeti_studenta.Location = new Point(50, 150);
            Controls.Add(svi_predmeti_studenta);


            Studenti student = (Studenti)cmbStudenti.SelectedItem;


            //dodavanje predmeta u checklistbox ako su sa smera ili u chombobox ako nisu sa istog smera
            foreach (Predmet p in predmeti)
            {
                if (p.Smer.ToString().Equals(student.Smer.ToString()))
                {
                    string unos = p.Naziv_predmeta + ",  " + p.Smer + ",  " + p.Semestar;
                    svi_predmeti_studenta.Items.Add(unos, (p.Obavezan) ?CheckState.Checked:CheckState.Unchecked);

                    if (p.Obavezan)
                    {
                        svi_predmeti_studenta.SetItemCheckState(svi_predmeti_studenta.Items.Count - 1, CheckState.Indeterminate);
                    }
                }
                else
                {
                    cmbPredmeti.Items.Insert(cmbPredmeti.Items.Count, p);
                }
            }


            btnDodaj.Enabled = true;

            //Trenutni ESPB bodovi
            broj = 0;
            for (int i = 0; i < svi_predmeti_studenta.Items.Count; i++)
            {
                if (svi_predmeti_studenta.GetItemCheckState(i) == CheckState.Checked || svi_predmeti_studenta.GetItemCheckState(i) == CheckState.Indeterminate)
                {
                    broj += 6;
                }
            }
            lblESPB.Text = "ESPB: " + broj;
        }
示例#15
0
        private void shape_box_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            CheckedListBox this_obj = sender as CheckedListBox;

            if (this_obj.CheckedItems.Count > 0)
            {
                for (int i = 0; i < this_obj.Items.Count; i++)
                {
                    if (i != e.Index)
                    {
                        this_obj.SetItemCheckState(i, CheckState.Unchecked);
                    }
                }
            }
        }
示例#16
0
 private void PastModeCheckBox_CheckedChanged(object sender, EventArgs e)
 {
     if (PastModeCheckBox.Checked == true)
     {
         TrueFX.enablepastmode();
         CheckedListBox copy = (CheckedListBox)(TrueFXMissionControlControl.Controls.Find("GraphPastData", true)[0]);
         copy.SetItemCheckState(0, CheckState.Unchecked);
         copy.SelectedIndex = 0; //To trigger the selected index change for the handler above.
         TrueFXMissionControlControl.Controls.Find("GraphPastData", true)[0].Visible = false;
     }
     else
     {
         TrueFXMissionControlControl.Controls.Find("GraphPastData", true)[0].Visible = true; TrueFX.disablepastmode();
     }
 }
示例#17
0
 private void butMoi_Click(object sender, System.EventArgs e)
 {
     try
     {
         stt.Value = decimal.Parse(d.get_data("select max(stt) from " + user + "." + table + " where nhom=" + i_nhom).Tables[0].Rows[0][0].ToString()) + 1;
     }
     catch { stt.Value = 1; }
     i_id     = 0;
     ten.Text = "";
     for (int k = 0; k < kho.Items.Count; k++)
     {
         kho.SetItemCheckState(k, CheckState.Unchecked);
     }
     for (int k = 0; k < nguon.Items.Count; k++)
     {
         nguon.SetItemCheckState(k, CheckState.Unchecked);
     }
     for (int k = 0; k < madoituong.Items.Count; k++)
     {
         madoituong.SetItemCheckState(k, CheckState.Unchecked);
     }
     ena_object(true);
     ten.Focus();
 }
示例#18
0
        private void checkFlagOrBitmask(CheckedListBox list, Type e, uint value)
        {
            if (!e.IsEnum)
            {
                return;
            }

            foreach (int i in list.CheckedIndices)
            {
                list.SetItemCheckState(i, CheckState.Unchecked);
            }

            var values = Enum.GetValues(e);

            for (int i = values.Length - 1; i > 0; i--)
            {
                uint val = Convert.ToUInt32(values.GetValue(i));
                if (val <= value)
                {
                    list.SetItemCheckState(i, CheckState.Checked);
                    value -= val;
                }
            }
        }
示例#19
0
 private void butMoi_Click(object sender, System.EventArgs e)
 {
     try
     {
         stt.Value = decimal.Parse(d.get_data("select max(madoituong) from " + user + "." + table).Tables[0].Rows[0][0].ToString()) + 1;
     }
     catch { stt.Value = 1; }
     for (int k = 0; k < nguon.Items.Count; k++)
     {
         nguon.SetItemCheckState(k, CheckState.Unchecked);
     }
     for (int k = 0; k < manhom.Items.Count; k++)
     {
         manhom.SetItemCheckState(k, CheckState.Unchecked);
     }
     for (int k = 0; k < makho.Items.Count; k++)
     {
         makho.SetItemCheckState(k, CheckState.Unchecked);
     }
     ten.Text           = "";
     loai.SelectedIndex = 0;
     ena_object(true);
     ten.Focus();
 }
示例#20
0
        private void Ckd_Lbx_SelectedIndexChanged(object sender, EventArgs e)
        {
            CheckedListBox cklbx = (sender as CheckedListBox);

            if (cklbx != null)
            {
                int index = cklbx.SelectedIndex;

                if (index > -1)
                {
                    CheckState ckState  = cklbx.GetItemCheckState(index);
                    CheckState setState = (ckState == CheckState.Checked) ? CheckState.Unchecked : CheckState.Checked;
                    cklbx.SetItemCheckState(index, setState);
                }
            }
        }
        private void chkLsbRight_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            CheckedListBox chkLSB = (CheckedListBox)sender;

            if (chkLSB.CheckedItems.Count > 0)
            {
                for (int i = 0; i < chkLSB.Items.Count; i++)
                {
                    if (i != e.Index)
                    {
                        chkLSB.SetItemCheckState(i,
                                                 System.Windows.Forms.CheckState.Unchecked);
                    }
                }
            }
        }
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            try
            {
                IWindowsFormsEditorService svc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                if (svc != null)
                {
                    if (value is string)
                    {
                        CheckedListBox clb = new CheckedListBox();
                        clb.ItemCheck += (object sender, ItemCheckEventArgs e) =>
                        {
                            for (int i = 0; i < clb.Items.Count; i++)
                            {
                                if (i != e.Index)
                                {
                                    clb.SetItemCheckState(i, System.Windows.Forms.CheckState.Unchecked);
                                }
                            }
                        };
                        foreach (var s in GlobalGeometryObject.SurfacePartList)
                        {
                            clb.Items.Add(s);
                        }
                        clb.BorderStyle = BorderStyle.None;
                        string partName = value as string;
                        for (int i = 0; i < clb.Items.Count; i++)
                        {
                            clb.SetItemChecked(i, clb.GetItemText(clb.Items[i]) == partName);
                        }
                        svc.DropDownControl(clb);
                        if (clb.SelectedItem != null)
                        {
                            partName = clb.GetItemText(clb.SelectedItem);
                        }
                        return(partName);
                    }
                }
            }
            catch (Exception ex)
            {
                return(value);
            }
            return(value);
        }
    // Load Categories information to CheckedListBox
    public static void LoadCategoryDataTo(CheckedListBox target, bool setCheckedDefault)
    {
        for (int i = 0; i < categories.Count; i++)
        {
            // Supress category all since it is not a category but a search function
            if (i != 0)
            {
                target.Items.Add(categories[i].name);
            }
        }

        // Set default check mark
        if (setCheckedDefault)
        {
            target.SetItemCheckState(0, CheckState.Checked);
        }
    }
示例#24
0
        private void Clb_Palvelut_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            CheckedListBox clb = (CheckedListBox)sender;

            // Switch off event handler
            clb.ItemCheck -= Clb_Palvelut_ItemCheck;
            clb.SetItemCheckState(e.Index, e.NewValue);
            // Switch on event handler
            clb.ItemCheck += Clb_Palvelut_ItemCheck;

            valitutpalvelut.Clear();
            PalveluidenHinta = 0;
            foreach (Service s in Clb_Palvelut.CheckedItems)
            {
                valitutpalvelut.Add(s);
                PalveluidenHinta += s.hinta;
            }
            Laskehinta();
        }
示例#25
0
        private void chLstBoxEvt_SelectedIndexChanged(object sender, ItemCheckEventArgs e)
        {
            CheckedListBox clb = (CheckedListBox)sender;

            // Switch off event handler
            clb.ItemCheck -= chLstBoxEvt_SelectedIndexChanged;
            clb.SetItemCheckState(e.Index, e.NewValue);
            // Switch on event handler
            clb.ItemCheck += chLstBoxEvt_SelectedIndexChanged;

            if (chLstBoxEvt.CheckedIndices.Count > 0)
            {
                button2.Enabled = true;
            }
            else
            {
                button2.Enabled = false;
            }
        }
示例#26
0
        private void CLBP_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            int            checkCount = int.Parse(lP.Text);
            CheckedListBox clb        = (CheckedListBox)sender;

            clb.ItemCheck -= CLBP_ItemCheck;
            clb.SetItemCheckState(e.Index, e.NewValue);
            clb.ItemCheck += CLBP_ItemCheck;
            lP.Text        = cLBP.CheckedItems.Count.ToString();
            if (checkCount < int.Parse(lP.Text))
            {
                cLBZ.Items.Remove(cLBP.Items[e.Index]);
                cLBO.Items.Remove(cLBP.Items[e.Index]);
            }
            else
            {
                cLBZ.Items.Add(cLBP.Items[e.Index]);
                cLBO.Items.Add(cLBP.Items[e.Index]);
            }
        }
示例#27
0
        private void ButtonFindSelect_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(TextBoxFindSelect.Text))
            {
                MessageBox.Show("Nothing to searching.", "No data", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int iTemp = CheckedListBox.FindString(TextBoxFindSelect.Text);

            if (iTemp != -1)
            {
                CheckedListBox.SetItemCheckState(iTemp, CheckState.Checked);
                CheckedListBox.SetSelected(iTemp, true);
            }
            else
            {
                MessageBox.Show("Nothing founded.", "Nothing", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void CLBContracts_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            CheckedListBox clb = (CheckedListBox)sender;

            clb.ItemCheck -= CLBContracts_ItemCheck;
            clb.SetItemCheckState(e.Index, e.NewValue);
            clb.ItemCheck += CLBContracts_ItemCheck;
            contracts      = new List <ContractDTO>();
            foreach (object contract in cLBContracts.CheckedItems)
            {
                contracts.Add(contract as ContractDTO);
            }
            var deliveryNotes = MainForm.DB.DeliveryNotes.GetAll().Where(x => contracts.Where(y => y.Id == MainForm.DB.Invoices.Get(x.InvoiceId).ContractId).Count() > 0);

            cLBDeliveryNotes.Items.Clear();
            foreach (DeliveryNoteDTO deliveryNote in deliveryNotes)
            {
                cLBDeliveryNotes.Items.Add(deliveryNote);
            }
        }
        /// <summary>
        /// Run asynchroniously to not stop XrmToolBox.
        /// </summary>
        private void OnIndexChanged(CheckedListBox listBox)
        {
            // Prevent from further clicking
            this.SetAllEnable(false);

            // Uncheck everything
            listBox.ClearAllSelections();
            // Set as checked only checked item
            listBox.SetItemCheckState(listBox.SelectedIndex, CheckState.Checked);

            // Checked User
            var userIndex = listBox.SelectedIndex;

            // Checked Model connected with User
            CurrentSelectedUser = this.Users.ElementAt(userIndex);
            // Calculate permissions for selected User
            CalculatePermissions();

            // After everything enable - enable Roles for future plans
            this.SetAllEnable(true);
        }
示例#30
0
        /// <summary>
        /// Set the contents of a checked list box
        /// </summary>
        /// <param name="ctlObj"></param>
        /// <param name="listTxt"></param>

        public static void SetCheckedListBox(
            Object ctlObj,
            string listTxt)
        {
            CheckedListBox ctl = (CheckedListBox)ctlObj;

            ctl.Items.Clear();
            string[] sa = listTxt.Split('\n');
            for (int i1 = 0; i1 < sa.Length; i1++)
            {
                string[] sa2 = sa[i1].Split('\t');
                if (sa2[0] == "")
                {
                    continue;
                }
                ctl.Items.Add(sa2[0]);
                int        csInt = Int32.Parse(sa2[1]);
                CheckState cs    = (CheckState)csInt;
                ctl.SetItemCheckState(ctl.Items.Count - 1, cs);
            }
        }