/// <summary> /// Constructor /// </summary> /// <param name="template"></param> protected MyOptionPicker(MyOptionPicker template) : base(template) { InitializeComponent(); Initialize(); this.ValueMember = template.ValueMember; this.DisplayMember = template.DisplayMember; this.DropDownSize = template.DropDownSize; this.DropDownControl.SetDataBinding(template.DropDownControl.DataSource, template.DropDownControl.DataMember); this.AdjustDropDownControlSize(); }
/// <summary> /// 重载KeyPress事件,当ComboBox为ReadOnly时,不处理KeyPress事件 /// </summary> /// <param name="e"></param> protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e) { MyOptionPicker box1 = this.ParentOptionPicker; box1.OnOwnKeyPress(e); if (!this.ReadOnly) { base.OnKeyPress(e); if (base.IsInputChar(e.KeyChar)) { if (e.KeyChar == (char)Keys.Enter) { return; } OwnTextChanged(); } } }
private static void SetSearchControlsValues(ISearchManager sm, bool allEmpty = false) { foreach (ISearchControl sc in sm.SearchControls) { if (allEmpty) { sc.SelectedDataValues = null; } else { IWindowControl wc = sc as IWindowControl; if (wc != null) { MyComboBox c = wc.Control as MyComboBox; if (c != null && c.Items.Count > 0) { c.SelectedIndex = 0; continue; } else { MyOptionPicker op = wc.Control as MyOptionPicker; if (op != null && op.DropDownControl.DataRows.Count > 0) { op.DropDownControl.DataRows[0].Cells[Feng.Grid.Columns.CheckColumn.DefaultSelectColumnName].Value = true; continue; } } } System.Collections.ArrayList arr = new System.Collections.ArrayList { }; if (sc.ResultType == typeof(DateTime)) { arr.Add(System.DateTime.Today); } else if (sc.ResultType == typeof(int)) { arr.Add(1); } else if (sc.ResultType == typeof(long)) { arr.Add(1L); } else if (sc.ResultType == typeof(string)) { arr.Add("1"); } else if (sc.ResultType == typeof(double)) { arr.Add(1.1d); } else if (sc.ResultType == typeof(decimal)) { arr.Add(1.1m); } else if (sc.ResultType == typeof(bool)) { arr.Add(true); } sc.SelectedDataValues = arr; } } }
/// <summary> /// OnKeyDown(Process Down Key) /// </summary> /// <param name="e"></param> protected override void OnKeyDown(KeyEventArgs e) { if (e.Control && (e.KeyCode == Keys.C || e.KeyCode == Keys.V || e.KeyCode == Keys.X)) { base.OnKeyDown(e); return; } try { MyOptionPicker box1 = ParentOptionPicker; if (!box1.ReadOnly) { GridControl grid = box1.DropDownControl; switch (e.KeyCode) { case Keys.Down: if (!box1.DroppedDown) { box1.DroppedDown = true; } MyComboBoxTextBoxArea.MoveCurrentRowDown(grid); e.Handled = true; if (!grid.Focused) { grid.Focus(); } break; case Keys.Up: if (box1.DroppedDown) { MyComboBoxTextBoxArea.MoveCurrentRowUp(grid); e.Handled = true; } break; case Keys.Enter: if (box1.DroppedDown) { box1.DroppedDown = false; } e.Handled = true; break; case Keys.Escape: if (box1.DroppedDown) { box1.DroppedDown = false; } e.Handled = true; break; } } } catch (Exception ex) { ExceptionProcess.ProcessWithResume(ex); } }
/// <summary> /// Constructor /// </summary> /// <param name="template"></param> protected MyOptionPickerEditor(MyOptionPicker template) : base(template) { }