Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6595759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:58:53+00:00 2026-05-25T17:58:53+00:00

I wanted a TextBox with just digits as entry. So i wrote following code

  • 0

I wanted a TextBox with just digits as entry. So i wrote following code in the KeyPress events of the textbox

if(!char.IsDigit(e.KeyChar))
{
    e.handled = true;
}

and it worked great. But I generally need them in many places of my application so then i wrote a partial class with following codes:

public partial class digitTextBox : TextBox
{
    public digitTextBox()
    {
        this.KeyPress += new KeyPressEventHandler(digitTextBox_KeyPress);
    }

    void digitTextBox_KeyPress(object sender, KeyPressEventArgs e)
    {
        if (char.IsDigit(e.KeyChar))
        {
            e.Handled = true;
        }
    }
}

build my solution and I got a control in my toolbox and even this was working perfectly fine.

But i had many TextBoxes with some or the other specification like, some should not accept special characters, some should accept decimals, some with decimals up to 2 digits after point….and so on and i do need these kind of controls in many applications.

So I thought of writing a Library(.dll) of my custom controls and if possible even for there validations. Honestly speaking I don’t have much idea about using libraries. So I made a library with 2 different kind of textboxes and created a .dll file out of them. Now I created a different winform application and I added reference of my custom control .dll file. But nothing happened.
So i just wanted to know what should be my approach in achieving it. Is there a better way to achieve these kind of tasks. and any new suggestions are also welcome. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:58:54+00:00Added an answer on May 25, 2026 at 5:58 pm

    Try right-mouse clicking the ToolBox and select “Choose Items…” and then select your controls from the available list. If you don’t see them, then click on the Browse button and select your DLL.

    On a side note, you might be able to combine your two textboxes by adding properties:

    public class MyTextBox : TextBox
    {
      public bool AllowDigitsOnly { get; set; }
    
      protected override void OnKeyPress(KeyPressEventArgs e)
      {
        if (this.AllowDigitsOnly)
        {
          if (!char.IsDigit(e.KeyChar))
            e.Handled = true;
        }
        base.OnKeyPress(e);
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to display the remaining characters using a label beside my textbox just
I just wanted to know how to display the remaining characters in my textbox,
I wanted to create a control with a TextBox and to bind TextBox.Text property
all, I wanted to create a multiline textbox but all the info i googled
Wanted to know if someone had a suggestion on code or maybe there's a
Just wanted to get an idea for ways (web) developers get round the short
I was given the following pseudo code in order to get the form that
I'm just getting into Dojo and wanted to try a simple AJAX Post like
This seemed like an easy thing to do. I just wanted to pop up
Just wanted a clear answer for a direct question -- google results have been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.