-
Jan 5th, 2008, 12:07 AM
#1
Thread Starter
Frenzied Member
[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.
-
Jan 5th, 2008, 12:17 AM
#2
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Jan 5th, 2008, 12:28 AM
#3
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:
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.
-
Jan 5th, 2008, 12:36 AM
#4
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.
-
Jan 5th, 2008, 12:51 AM
#5
Thread Starter
Frenzied Member
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.
-
Jan 5th, 2008, 01:27 AM
#6
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.
-
Jan 5th, 2008, 01:29 AM
#7
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Jan 5th, 2008, 01:30 AM
#8
Re: [2.0] How can I make a UserControl only change its width and not height?
Your in the C# Forum Rob
-
Jan 5th, 2008, 01:38 AM
#9
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|