|
-
Jan 23rd, 2008, 02:40 PM
#1
Thread Starter
Addicted Member
[RESOLVED] [2008] Create my own textbox
Hi all
I want to create my own control like a textbox with more properties...
I know that I should use "Inherits the textbox" but don't understand how?
I've tried to create a usercontrol and inside a textbox... but I couldn't change the size of the textbox inside the usercontrol...
So I tried to created my own class and inherits the textbox class... and add my properties that I need...
I want to be able to drag from the toolbox my control and the idea is that it will look and behave like the textbox but with my additional properties and methods... thanks
-
Jan 23rd, 2008, 02:47 PM
#2
Re: [2008] Create my own textbox
Create and compile your user control. Right-click on the toolbox and select "Choose Items". There's a "Browse" button there that lets you navigate to the executable for the control you just compiled. Select that and it will show up on the toolbox and you can drag it onto your form.
-
Jan 23rd, 2008, 02:51 PM
#3
Re: [2008] Create my own textbox
If by resize you mean resize its height then no you cant unless you make it multiline.
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 23rd, 2008, 02:54 PM
#4
Re: [2008] Create my own textbox
Controls inside a user-control can not be resized from the form, you'll have to go into the usercontrols design-view and change it. But the best thing would be, as you mentioned, to inherit the TextBox.
You should create a new class by clicking "New item.." in the Project menu, Simply add "Inherits TextBox, on the second line of your new class. It will now inherit from the TextBox and you're free to add new members to it as you please.
-
Jan 23rd, 2008, 02:57 PM
#5
Re: [2008] Create my own textbox
But remember that by only using a class that inherits the textbox you wil have to manually add a regular textbox control to your for and then modify the designer code to point to your class instance as there is no toolbox item to drop for an inherited class.
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 23rd, 2008, 03:12 PM
#6
Re: [2008] Create my own textbox
-
Jan 23rd, 2008, 03:18 PM
#7
Re: [2008] Create my own textbox
Oops, needed to hit Build
Bad Robdog! * SLAP * 
I was just working with 2003 which doesnt do that for you.
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 23rd, 2008, 03:35 PM
#8
Thread Starter
Addicted Member
Re: [2008] Create my own textbox
ok it works...
All my new properties are under "Misc" category is there a code to change this?
-
Jan 23rd, 2008, 04:06 PM
#9
Re: [2008] Create my own textbox
There should be a Category attribute that you can add to the property that will place it where it needs to be:
<Category("General")> _
public property X () ...
I'm not sure if it needs to be a category that already exists and you have to do something else to add new ones or if it creates a new category if the one that's listed there doesn't already exist.
-
Jan 23rd, 2008, 04:07 PM
#10
Thread Starter
Addicted Member
Re: [2008] Create my own textbox
and also but not very important... how can I change the icon for my class... I don't like that wheel
-
Jan 23rd, 2008, 04:14 PM
#11
Re: [2008] Create my own textbox
 Originally Posted by mnavas
and also but not very important... how can I change the icon for my class... I don't like that wheel
Use the ToolBoxBitmap attribute.
If you have a 16x16 bitmap you want to use:
VB.Net Code:
<ToolboxBitmap("c:\someFile.bmp")> _
Public Class Class1
End Class
If you want to use the bitmap of an existing control:
VB.Net Code:
<ToolboxBitmap(GetType(TextBox))> _
Public Class Class1
End Class
-
Jan 23rd, 2008, 04:19 PM
#12
Re: [2008] Create my own textbox
Its a gear 
If you link a file on your system, it will get compiled into the exe as a internal resource so distributing the image file is not an issue.
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 23rd, 2008, 04:22 PM
#13
Thread Starter
Addicted Member
Re: [2008] Create my own textbox
Am I missing something? Do I need to import something?
I got this error
type 'toolboxbitmap' is not defined
-
Jan 23rd, 2008, 04:30 PM
#14
Re: [2008] Create my own textbox
You shouldnt have to. Its in the System.Drawing class just in case.
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
|