Results 1 to 10 of 10

Thread: Numberbox Control

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Numberbox Control

    I was wondering if there's some control for a textbox that only accepts numbers.

    I know there is the NumericUpDown control but that does't behave in the way I want.

    Martin Liss created a control in VB6. See here.

    The control only accepts numbers, and has properties such as
    CanBeNegative
    MaxValue
    NinValue
    MaxDecimals

    Is there a similar control in .NET? And can you create new controls in .NET if one doesn't exist?

  2. #2
    Frenzied Member Campion's Avatar
    Join Date
    Jul 2007
    Location
    UT
    Posts
    1,098

    Re: Numberbox Control

    I'm sure some exist out there, but you can always make your own by creating a custom control that inherits TextBox. Plus, you'll have more control over how YOU want it to behave.
    From my burrow, 2 feet under.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Re: Numberbox Control

    jmcilhinney,

    I've downloaded and installed the component but can't find where to use it.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Numberbox Control

    You have to add the controls the library contains (or at least the ones you want to use) to your Toolbox and you use them the same way you use any other controls.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6
    Lively Member
    Join Date
    Oct 2007
    Location
    Upper Midwest
    Posts
    123

    Re: Numberbox Control

    Yes, you can create user controls in .NET. I would start by referencing this link from the MSDN website:

    http://msdn.microsoft.com/en-us/libr...sc(VS.85).aspx

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Numberbox Control

    Quote Originally Posted by Tealmad View Post
    Yes, you can create user controls in .NET. I would start by referencing this link from the MSDN website:

    http://msdn.microsoft.com/en-us/libr...sc(VS.85).aspx
    A user control and a custom control are not the same thing. What's more, that topic is for ASP.NET, not WinForms.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8
    Lively Member
    Join Date
    Oct 2007
    Location
    Upper Midwest
    Posts
    123

    Re: Numberbox Control

    Sorry jmcilhinney. I assumed that is what he was looking for based on the comment of creating a control if one doesn't exist.

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Numberbox Control

    Quote Originally Posted by Tealmad View Post
    Sorry jmcilhinney. I assumed that is what he was looking for based on the comment of creating a control if one doesn't exist.
    Officially, a user control is a control that acts as a container for other controls, while a custom control is one that either inherits Control directly and provides new functionality or else inherits an existing control and provides additional functionality. Of course, a user control inherits an existing control too, i.e. UserControl, but its express purpose is to contain other controls.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  10. #10
    Hyperactive Member Philly0494's Avatar
    Join Date
    Apr 2008
    Posts
    485

    Re: Numberbox Control

    making a textbox do this is incredibly easy to do in C++, as it is an inherent property of the Win32 Edit control.

    For some reason vb.NET decided to not support that, so you will have to make a custom control, or import one that someone else has made

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