/// <summary> /// Drops the editor control. /// </summary> /// <param name="ctl">The control to drop.</param> public void DropDownControl(Control ctl) { if (genericValueDropDownForm == null) { genericValueDropDownForm = new GenericValueDropDownForm(this); } genericValueDropDownForm.Visible = false; genericValueDropDownForm.Component = ctl; Rectangle editorBounds = editor.Bounds; Size size = genericValueDropDownForm.Size; // location of the form Point location = new Point(editorBounds.Right - size.Width, editorBounds.Bottom + 1); // location in screen coordinate location = editor.Parent.PointToScreen(location); // 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.TextBox.Height > screenWorkingArea.Bottom) { location.Y = location.Y - size.Height - editorBounds.Height - 1; } genericValueDropDownForm.SetBounds(location.X, location.Y, size.Width, size.Height); genericValueDropDownForm.Visible = true; ctl.Focus(); editor.SelectTextBox(); // wait for the end of the editing while (genericValueDropDownForm.Visible) { Application.DoEvents(); MsgWaitForMultipleObjects(0, 0, true, 250, 255); } // editing is done or aborted }