public void DropDownControl(Control ctl) { Point location = new Point(Editor.Left, Editor.Bottom); // location in screen coordinate location = Editor.Parent.PointToScreen(location); if (ddForm == null) { ddForm = new DropDownFormBase(this, (IDropDownControl)ctl); } ddForm.Visible = false; Size size = new Size(Editor.Width, ctl.Height); if (DropDownFormBorderStyle == FormBorderStyle.FixedSingle || DropDownFormBorderStyle == FormBorderStyle.FixedToolWindow) { size.Width = ddForm.Width; } // check the form is in the screen working area Rectangle screenWorkingArea = Screen.FromControl(Editor).WorkingArea; location.X = Math.Min(screenWorkingArea.Right - size.Width, Math.Max(screenWorkingArea.X, location.X)); if (size.Height + location.Y + Editor.Height > screenWorkingArea.Bottom) { location.Y = location.Y - size.Height - Editor.Height - 1; } ddForm.Location = location; ddForm.Size = size; ddForm.Visible = true; ctl.Visible = true; if (set != null) { int index = -1; if (Editor.Value != null) { index = set.IndexOf(Editor.Value); } BindingManagerBase cm = ddControl.Grid.BindingContext[set]; if (cm != null) { cm.Position = index; } } ((IDropDownControl)ctl).Grid.Focus(); }
public DropDownController(ChooserEditor editor, IDropDownControl ctl, CS bset, bool reload) : base(editor, bset, reload) { ddControl = ctl; ddForm = new DropDownFormBase(this, ddControl); ddControl.Grid.DataSource = set; ddControl.RowEntered += new EventHandler <EventArgs <int> >(ddControl_RowEntered); ddControl.RowSelected += new EventHandler <EventArgs <int> >(ddControl_RowSelected); ddControl.DropDownClosed += new EventHandler(ddControl_DropDownClosed); Editor = editor; Editor.ValueDropDown += Editor_ValueDropDown; //Editor.ValueChanged += new EventHandler(Editor_ValueChanged); }