Results 1 to 14 of 14

Thread: [RESOLVED] [2008] Create my own textbox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Posts
    134

    Resolved [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

  2. #2
    Frenzied Member
    Join Date
    May 2006
    Location
    Toronto, ON
    Posts
    1,093

    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.

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  4. #4
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    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.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  6. #6
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2008] Create my own textbox

    Quote Originally Posted by RobDog888
    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.
    It appears in the toolbox if you just build your project doesnt i? It does for me Unless I'm confusing myself right now
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Posts
    134

    Re: [2008] Create my own textbox

    ok it works...

    All my new properties are under "Misc" category is there a code to change this?

  9. #9
    Frenzied Member
    Join Date
    May 2006
    Location
    Toronto, ON
    Posts
    1,093

    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.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Posts
    134

    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

  11. #11
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2008] Create my own textbox

    Quote 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:
    1. <ToolboxBitmap("c:\someFile.bmp")> _
    2. Public Class Class1
    3.  
    4. End Class

    If you want to use the bitmap of an existing control:
    VB.Net Code:
    1. <ToolboxBitmap(GetType(TextBox))> _
    2. Public Class Class1
    3.  
    4. End Class
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Posts
    134

    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

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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
  •  



Click Here to Expand Forum to Full Width