private void ShowDropDown(Control hostedControl, Color borderColor) { hostedControl.Width = Math.Max(hostedControl.Width, EditRegionSize.Width - 2); _dropDownHolder = new DropDownHolder(hostedControl, ActionPanel, borderColor, ActionPanel.Font, this); if (ActionPanel.RightToLeft != RightToLeft.Yes) { Rectangle editorBounds = new Rectangle(Point.Empty, EditRegionSize); Size dropDownSize = _dropDownHolder.Size; Point editorLocation = ActionPanel.PointToScreen(EditRegionLocation); Rectangle rectScreen = Screen.FromRectangle(ActionPanel.RectangleToScreen(editorBounds)).WorkingArea; dropDownSize.Width = Math.Max(editorBounds.Width + 1, dropDownSize.Width); editorLocation.X = Math.Min(rectScreen.Right - dropDownSize.Width, // min = right screen edge clip Math.Max(rectScreen.X, editorLocation.X + editorBounds.Right - dropDownSize.Width)); // max = left screen edge clip editorLocation.Y += editorBounds.Y; if (rectScreen.Bottom < (dropDownSize.Height + editorLocation.Y + editorBounds.Height)) { editorLocation.Y -= dropDownSize.Height + 1; } else { editorLocation.Y += editorBounds.Height; } _dropDownHolder.Location = editorLocation; } else { _dropDownHolder.RightToLeft = ActionPanel.RightToLeft; Rectangle editorBounds = new Rectangle(Point.Empty, EditRegionSize); Size dropDownSize = _dropDownHolder.Size; Point editorLocation = ActionPanel.PointToScreen(EditRegionLocation); Rectangle rectScreen = Screen.FromRectangle(ActionPanel.RectangleToScreen(editorBounds)).WorkingArea; dropDownSize.Width = Math.Max(editorBounds.Width + 1, dropDownSize.Width); editorLocation.X = Math.Min(rectScreen.Right - dropDownSize.Width, // min = right screen edge clip Math.Max(rectScreen.X, editorLocation.X - editorBounds.Width)); // max = left screen edge clip editorLocation.Y += editorBounds.Y; if (rectScreen.Bottom < (dropDownSize.Height + editorLocation.Y + editorBounds.Height)) { editorLocation.Y -= dropDownSize.Height + 1; } else { editorLocation.Y += editorBounds.Height; } _dropDownHolder.Location = editorLocation; } ActionPanel.InMethodInvoke = true; ActionPanel.SetDropDownActive(true); try { _dropDownHolder.ShowDropDown(_button); } finally { _button.ResetMouseStates(); ActionPanel.SetDropDownActive(false); ActionPanel.InMethodInvoke = false; } }