I need to create a combo box with an overlayed button like the one in the Toolbox panel of Visual Studio:
I created a control derived from System.Windows.Forms.UserControl with a PictureBox onto a System.Windows.Forms.ComboBox.
The problem is that when the text is too long, it starts scrolling after the PictureBox, going under it. I tried setting the MaxLength property of the ComboBox appropriately, but in this way the user would be limited in the number of characters he could enter because the text doesn't scroll.
What can I do to achieve the desired functionality?
Related
I have tried to search this question but most of the questions I've seen deal with how to place a user control into a group box in winforms. I have a slightly different question.
I have a form that contains a combo box and group box. I have a series of user controls that I want to swap in and out of the group box depending on the combo box selection. This all works perfectly fine.
The issue I am running into is that it seems to place the user control in the top left corner of the group box. This obscures the border and any text on the group box itself. I have tried changing the Padding in the group box and also the margins on the user control and nothing appears to change how the group box places the control.
I'm aware I can use a panel or manually place the controls after they are added, but I was hoping someone might know how the group box determines where to place controls and why it seems like padding/margins are being ignored.
Does padding only matter when the group box has multiple controls and the user control is being seen as a single control that doesn't need padded?
Set the UserControl's Dock property to Fill when inside the GroupBox.
The Dock property uses the DisplayRectangle property of the parent control, which will respect the interior border area the GroupBox uses for the text caption and border lines.
The form is a complex construction with label and text controls at the top, a tab control at the bottom, and data grid views in some of the tab pages. I had just resized the fonts in most of the controls on the form from '8' (8.25) to '10' (9.75). Having saved it, when I reopen it numerous controls in the tab pages have either disappeared entirely or are improperly dimensioned, usually scrunched up in the upper left hand corner. Among the malformed controls are data grid views, multi-line text boxes, labels, and buttons. If I reposition and resize the forms, they are 'saved', but not to the dimensions I specify. Generally when this happens I find the entire form is beyond recovery.
Why does it happen, and what should I do to keep it from happening again?
Update:
I have another form with a similar arrangement: text boxes at the top for the 'main record', a tab collection at the bottom, and custom user controls embedded in two of the pages. Changing the font style on the tab control properties corrupted many of the controls in the subordinate pages. This was particularly true of the two custom user controls, both of which contain DataGridViews. However, some tab pages have nothing more than a multi-line text box, and these were also corrupted. I suspect that the controls that were corrupted were anchored on all four sides, certain text and label controls only anchored top-left weren't affected.
I locked the controls before applying the font style, locking does not change the outcome.
In my Custom control, i have issue with drop down menu height. If Combo box items are more, I want scroll mouse many times because of small height of Drop down menu. I want to increase the height of Drop down menu.
FYI - I have generate Custom Control using Generic.xaml file and behavior's of the control are defined in TextBox.cs file (inherited from the Text Box Class).
Thank You..!!
You can use the MaxDropDownHeight Property of your ComboBox to set the desired maximum height you want for it, when unfolded that is.
In my Winforms application I have a toolbar that contains many items (buttons with icon 32px, labels and comboboxes).
I decided to set the Toolstrip.LayoutStyle property from the default HorizontalStackWithOverflow to Flow in order to allow the toolbar split automatically on more rows when user have a very low resolution monitor or he/she resize the window.
The problem is that all labels and comboboxes are aligned to the top of Toolstrip when I change the LayoutStyle.
Does exist a property or any other workaround that allow me to center them vertically?
I think I see what you mean, the label isn't as tall as, say, a button. And it gets aligned improperly with LayoutStyle = Flow. Ugh. You can work around it by changing the Padding property of the label. To do this properly, you should however do this in the form's OnLoad() method override, the label will be taller when you run on a machine with a higher video DPI setting.
In Visual Studio (2008) when you place a textbox on a Windows Form, and drag it around, you see very helpful guidelines which help you align it (left, right, top or bottom) to other controls. You also see a line the represents the bottom of the text in that control helping you align the text within your textbox, to the text within a label, regardless of the height of that label.
I have user control that contains a textbox and a couple of buttons. Can I force the VS2008 designer to show me the same line for the bottom of the text, from the textbox within my user control? If so, how?
Seems like this answer might be what you need - Baseline snaplines in custom Winforms controls