[2.0] How can I make a UserControl only change its width and not height?
The exact way a TextBox is like. My user control is of only a textbox. Also, if it is set to Multiline, then the user control can then also be height resizable. Thanks.
Re: [2.0] How can I make a UserControl only change its width and not height?
Override the OnResize event and reset the width to a constant value.
Or Shadow the Size property and force the width
Re: [2.0] How can I make a UserControl only change its width and not height?
Looking at the TextBox class definition in Reflector I see that it has the Designer attribute applied and the TextBoxDesigner class specified. I would guess that it is that that controls that behaviour in the TextBox class. Design-time behaviour is almost always controlled via attributes, and the documentation for the DesignerAttribute class describes it as:
Quote:
Specifies the class used to implement design-time services for a component.
It would follow that you need to create a custom designer for your class. Maybe you can use the TextBoxDesigner class yourself, but I'd guess that it's an internal (Friend) class.
Re: [2.0] How can I make a UserControl only change its width and not height?
Given that your UserControl consists of only a TextBox, I'm wondering why you chose to implement it that way instead of simply deriving your own control from the TextBox class. I would think that that would be easier and it would mean that the control itself already has this behaviour.
Re: [2.0] How can I make a UserControl only change its width and not height?
So would I just derive from Textbox instead of UserControl, because I cannot derive from both.
Re: [2.0] How can I make a UserControl only change its width and not height?
What value is deriving from UserControl providing? If there is none then you should be deriving from TextBox.
Re: [2.0] How can I make a UserControl only change its width and not height?
If you create a UserControl project you will see it inherits from the UserControl in its designer class.
Code:
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class UserControl1
Inherits System.Windows.Forms.UserControl
Re: [2.0] How can I make a UserControl only change its width and not height?
Your in the C# Forum Rob ;)
Re: [2.0] How can I make a UserControl only change its width and not height?
Well it was for demonstration purposes only as you wouldnt write that designer gnerated code anyways. But if you want to see C# then here it is. ;)
Code:
[Microsoft.VisualBasic.CompilerServices.DesignerGenerated()]
internal partial class UserControl1 : System.Windows.Forms.UserControl