Combobox Dropdown

I have a form that has a summary on it.

Drop-down list set by DropDownList. These drop-down elements are a descriptive form of the object. This means that they can get quite a lot of time. The position of the drop-down list on the screen means that when the drop-down list is displayed, it does not fit the screen. Some of them are cut off by the right edge of the screen.

I can not move the combobox.

Is this somehow, I can move the drop down part of the control list. Perhaps focus it under control?

Update

I attached a screenshot. You can see the form here -

enter image description here

When entering transactions, the user fills out the form and clicks the "Save" button. The series of transactions that will be entered for any client will be recurring transactions. They can be saved as favorites. The drop-down list lists the currently saved favorites, and when one of them is selected, the program automatically fills in the transaction fields.

Screenshot 2 showing the entire program and a list of lists with a list of exclusions from space.

enter image description here

I understand that in the screenshot I could move the form, but I like to save forms for entering transactions in the center of the screen.

I may have to look at other interface options.

Thanks,

+6
source share
4 answers

perhaps you should create your own comboBox as shown below:

http://msdn.microsoft.com/en-us/library/ms996411

+2
source

You tried to install in the designer

Combobox.Anchor = Left | Right 
0
source

Try installing DropdownWidth combos.

0
source

Sorry for posting late :-). Yes you can do it. But you need to create a custom ComboBox and override the WndProc method of the ComboBox base;

Like this:

 System.Runtime.InteropServices private const int SWP_NOSIZE = 0x1; private const int WM_CTLCOLORLISTBOX = 0x0134; [DllImport("user32.dll")] static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); protected override void WndProc(ref Message m) { if (m.Msg == WM_CTLCOLORLISTBOX) { // Make sure we are inbounds of the screen int left = this.PointToScreen(new Point(0, 0)).X; //Only do this if the dropdown is going off right edge of screen if (this.DropDownWidth > Screen.PrimaryScreen.WorkingArea.Width - left) { // Get the current combo position and size Rectangle comboRect = this.RectangleToScreen(this.ClientRectangle); int dropHeight = 0; int topOfDropDown = 0; int leftOfDropDown = 0; //Calculate dropped list height for (int i = 0; (i < this.Items.Count && i < this.MaxDropDownItems); i++) { dropHeight += this.ItemHeight; } //Set top position of the dropped list if //it goes off the bottom of the screen if (dropHeight > Screen.PrimaryScreen.WorkingArea.Height - this.PointToScreen(new Point(0, 0)).Y) { topOfDropDown = comboRect.Top - dropHeight - 2; } else { topOfDropDown = comboRect.Bottom; } //Calculate shifted left position leftOfDropDown = comboRect.Left - (this.DropDownWidth - (Screen.PrimaryScreen.WorkingArea.Width - left)); //when using the SWP_NOSIZE flag, cx and cy params are ignored SetWindowPos(m.LParam, IntPtr.Zero, leftOfDropDown, topOfDropDown, 0, 0, SWP_NOSIZE); } } base.WndProc(ref m); } 

The code comes from an MSDN article Creating a Better ComboBox

0
source

Source: https://habr.com/ru/post/893603/


All Articles