private void frmMutiThreadingEDit_Load(object sender, EventArgs e) { this.MinimumSize = this.Size; this.MaximumSize = this.Size; // Adding Gender Combo box item text and value...... RoobDAL.ComboBoxValue item = new ComboBoxValue(); item.Text = "Female"; item.Value = 1; cmbGender.Items.Add(item); RoobDAL.ComboBoxValue item1 = new ComboBoxValue(); item1.Text = "Male"; item1.Value = 2; cmbGender.Items.Add(item1); cmbGender.SelectedIndex = -1; //Ending..... // Adding Active Combo box item text and value...... RoobDAL.ComboBoxValue item2 = new ComboBoxValue(); item2.Text = "Yes"; item2.Value = 1; cmbActive.Items.Add(item2); RoobDAL.ComboBoxValue item3 = new ComboBoxValue(); item3.Text = "No"; item3.Value = 2; cmbActive.Items.Add(item3); cmbActive.SelectedIndex = -1; //Ending..... Person p = new Person(); p.Id = Id; if (p.SelectById()) { txtName.Text = p.Name; txtContact.Text = p.ContactNo; txtEmail.Text = p.Email; txtBalance.Text = p.Balance.ToString(); txtCnId.Text = p.CnId.ToString(); txtNote.Text = p.Note; txtAddress.Text = p.Address; cmbGender.SelectedValue = p.Gender; cmbActive.SelectedValue = p.Active; cmbUserType.SelectedItem = p.UserType; dtpEntryDate.Value = p.EntryDate; } else { MessageBox.Show(p.Error); } }
private void InitOverwriteModeComboBox() { var defaultOverwriteMode = new ComboBoxValue <OverwriteMode>(OverwriteMode.Overwrite, "Overwrite existing files"); _overwriteModes = new ObservableCollection <ComboBoxValue <OverwriteMode> >() { defaultOverwriteMode, new ComboBoxValue <OverwriteMode>(OverwriteMode.Backup, "Backup existing files"), new ComboBoxValue <OverwriteMode>(OverwriteMode.Skip, "Skip existing files") }; OverwriteModeComboBox.SelectedItem = defaultOverwriteMode; OverwriteModeComboBox.ItemsSource = _overwriteModes; }
private void frmMultiThreading_Load(object sender, EventArgs e) { this.MinimumSize = this.Size; this.MaximumSize = this.Size; //Adding Gender Combo box item text and value...... RoobDAL.ComboBoxValue item = new ComboBoxValue(); item.Text = "Female"; item.Value = 1; cmbGender.Items.Add(item); RoobDAL.ComboBoxValue item1 = new ComboBoxValue(); item1.Text = "Male"; item1.Value = 2; cmbGender.Items.Add(item1); cmbGender.SelectedIndex = -1; //cmbGender.Items.Insert(0,"Male"); //cmbGender.Items.Insert(1, "FeMale"); //Ending..... // Adding Active Combo box item text and value...... RoobDAL.ComboBoxValue item2 = new ComboBoxValue(); item2.Text = "Yes"; item2.Value = 1; cmbActive.Items.Add(item2); RoobDAL.ComboBoxValue item3 = new ComboBoxValue(); item3.Text = "No"; item3.Value = 2; cmbActive.Items.Add(item3); cmbActive.SelectedIndex = -1; //Ending..... }
private void btnSubmit_Click(object sender, EventArgs e) { //if (this.combType.SelectedIndex == -1) if (this.combType.Text == "") { MessageBox.Show("请选择或者输入需要添加的类型!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); return; } else { if (this.txtText.Text.ToString() == null || this.txtText.Text.ToString() == "") { MessageBox.Show("文本值不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); this.txtText.Focus(); return; } if (this.txtValue.Text.ToString() != "") { if (_comboValue.IsExsitsComboBoxValue(this.txtValue.Text.ToString(), this.combType.Text.ToString())) { MessageBox.Show("该value值已经存在请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); this.txtValue.Focus(); return; } } ComboBoxValue cbv = new ComboBoxValue(); string msg; //if (!this.OperModifyStatus) //{ cbv.COMBID = Guid.NewGuid().ToString(); msg = "添加成功"; //} //else //{ // //cbv.COMBID = this.dgvExt.CurrentRow.Cells["COMBID"].Value.ToString(); // cbv= _comboValue.GetComboBoxItemByComboID(this.dgvExt.CurrentRow.Cells["COMBID"].Value.ToString()); // msg = "修改成功"; //} cbv.COMBDESC = this.txtDesc.Text.ToString(); cbv.COMBTYPE = this.combType.Text.ToString(); cbv.COMBTEXT = this.txtText.Text.ToString(); if (this.txtValue.Text.ToString() == "") { //cbv.COMBVALUE = Guid.NewGuid().ToString(); cbv.COMBVALUE = cbv.COMBID; } else { cbv.COMBVALUE = this.txtValue.Text.ToString(); } cbv.Save(); MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); // this.OperModifyStatus = false; btnClear_Click(sender, e); iniEvent(); } }
// callbacks private void UserControl_Loaded(object sender, RoutedEventArgs e) { // save data context var dc = IndividualDataContext.CreateDataContext(this.DataContext); if (dc == null) { return; } // forward the data context to the base cub contol SubControlBase.DataContext = this.DataContext; // first, do fundamental initialisation if (dc.desc.comboBoxChoices != null && dc.desc.comboBoxChoices.Length > 0) { // make Comboxbox visible TextBoxValue.Visibility = Visibility.Hidden; ComboBoxValue.Visibility = Visibility.Visible; // initialize with choices ComboBoxValue.Items.Clear(); foreach (var cbc in dc.desc.comboBoxChoices) { ComboBoxValue.Items.Add(cbc); } // editable, if valueFromComboBoxIndex[] is null var editableMode = (dc.desc.valueFromComboBoxIndex == null || dc.desc.valueFromComboBoxIndex.Length < 1); ComboBoxValue.IsEditable = editableMode; // update property ComboBoxValue.SelectionChanged += (object sender2, SelectionChangedEventArgs e2) => { var idx = ComboBoxValue.SelectedIndex; var items = dc.desc.valueFromComboBoxIndex; if (items != null && items.Length > 0 && idx >= 0 && idx < items.Length && !editableMode) { if (!UpdateDisplayInCharge) { dc.instance.Touch(); dc.prop.value = "" + items[idx]; // test var ndx = dc.instance.Index; dc.instance?.parentInstance.TriggerSlaveEvents(dc.instance, ndx); } } }; // update property (don't knwo to realize as lambda) ComboBoxValue.AddHandler(System.Windows.Controls.Primitives.TextBoxBase.TextChangedEvent, new System.Windows.Controls.TextChangedEventHandler(ComboBox_TextChanged)); } else { // make Textbox visible TextBoxValue.Visibility = Visibility.Visible; ComboBoxValue.Visibility = Visibility.Hidden; // slave value? if (dc.desc.SlaveOfIdShort != null && dc.desc.SlaveOfIdShort.Length > 0) { this.TextBoxValue.IsReadOnly = true; } // update property TextBoxValue.TextChanged += (object sender3, TextChangedEventArgs e3) => { if (!UpdateDisplayInCharge) { dc.instance.Touch(); } dc.prop.value = TextBoxValue.Text; }; } // then update UpdateDisplay(); }