public static void AddNotExists(this ComboBox.ObjectCollection items, object value) { if (items.Contains(value)) { return; } items.Add(value); }
/* protected override void WndProc(ref Message m) * { * if(m.Msg ==WM_DEVICECHANGE) * { * ; * ; * } * base.WndProc(ref m); * }*/ /// <summary> /// 扫描枪下拉列表项添加处理函数 /// </summary> /// <param name="obj"></param> public void ComBoBoxaddListItem(List <SerSystemDiscoverer.SystemInfo> obj) { ComboBox.ObjectCollection objectCollection = comboBox1.Items; obj.ForEach(o => { if (!objectCollection.Contains(o.PortName)) { comboBox1.Items.Add(o.PortName); } ; }); }
private void AddDateToFilterPanel(DateTime date) { if (!availableYears.Contains(date.Year)) { availableYears.Add(date.Year); } if (!availableMonths.Contains(date.Month)) { availableMonths.Add(date.Month); } if (!availableDays.Contains(date.Day)) { availableDays.Add(date.Day); } }
private void LayoutFormSaveButton_Click(object sender, EventArgs e) { if (NameTexbox.Text.Length < 1) { MessageBox.Show("Name requires a minimum of 1 character!", "Invalid Name", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (ExistingLayouts.Contains(NameTexbox.Text)) { MessageBox.Show("That layout name is alredy in use. Layout names must be unique!", "Invalid Name", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { name = NameTexbox.Text; DialogResult = DialogResult.OK; Close(); } }