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

  • Home
  • SEARCH
  • 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 7727175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:23:38+00:00 2026-06-01T05:23:38+00:00

I am using a windows form and within the form i have a user

  • 0

I am using a windows form and within the form i have a user control with two labels, one that has a message ENTER AMOUNT and the other where I am putting the values typed by the user (like when you go to an ATM) it starts showing the number .. it works fine if i dont have any other controls on the user control.. but the moment i add a button it does not work, it wont start showing the numbers as I use my numeric key pad.. but if i remove whatever button i added it works again… Here is my user control code.

 public partial class OperationAmount : UserControl
    {
        public OperationAmount()
        {
            InitializeComponent();
        }

        private int _inputNumber = 0;

        private void OperationAmount_Load(object sender, EventArgs e)
        {
        }

        private void Form_KeyAmountPressed(object sender, KeyPressEventArgs e)
        {
            if (!Char.IsNumber(e.KeyChar))
            {
                return;
            }
            else if (lblOperationAmount.Text.Length > 9)
            {
                return;
            }
            else
            {
                _inputNumber = 10 * _inputNumber + Int32.Parse(e.KeyChar.ToString());
                ReformatOutput();
            }
        }

        private void ReformatOutput()
        {
            lblOperationAmount.Text = String.Format("{0:0.00}", (double)_inputNumber / 100.0);
        }

    }
  • 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-06-01T05:23:39+00:00Added an answer on June 1, 2026 at 5:23 am

    Probably the new control steals the keypresses from your Form_KeyAmountPressed method because now it has the focus and receive the event KeyPress.
    A simple workaround would be to add the method Form_KeyAmountPressed also at the KeyPress event of the button. Try also to set the TabStop property of the button to false. (not sure if this has any effect when the button is the only control that can get focus on your user control).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using c# .net windows form application. i have a SQL database with 5
Im using c# .net windows form application. I have many databases created using sql
Im using c# .net windows form application. I have loaded names of all the
Im using c# .net windows application form. I have created many databases with many
I have a c# windows form project using watin. I would love to attach
I'm using C# and I have windows form and web service... I have a
I have datagridviews on windows form, i am adding records to datagridview using small
I have to embed an .exe within a panel in a .net windows form.
I have a windows form application that will open other forms, but will only
I have created a Windows form using Visual C# - this contains a rich

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.