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 8372177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:21:32+00:00 2026-06-09T14:21:32+00:00

I have two forms. On the first form I have a virtual numpad (I

  • 0

I have two forms. On the first form I have a virtual numpad (I have a GroupBox and inside I have number buttons and this is my virtual numpad). With this virtual numpad I enter numbers into a TextBox. On the second form I have another TextBox where I enter numbers.

I want to use my virtual numpad on this second form. How can I do that?

If someone explained to me what I should do, step by step, I will be pleased.

  • 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-09T14:21:34+00:00Added an answer on June 9, 2026 at 2:21 pm

    1) Create a WinForms project, I called it “ReusingUserControlsSample”
    2) Create a new UserControl, name it MyUserControlWithButtons or whatever else you like
    3) Just out of habit, set “AutoSize=true” and AutoSizeMode=”GrowAndShrink” on the UserControl properties. Later you may learn what they do
    4) On the UserControlDesigner place some button on the control, name them “btnLetterA”, “btnLetterB”, “btnLetterC”
    5) Double click on each of the buttons, so the click-handlers will be generated
    6) In your UserControl’s code, make a public TextBox TheOutput property
    7) In your UserControl’s code, in each of the click-handlers you’ve generated in step (5), add a line that adds some text to the TheOutput textbox’s TextBox property. Remeber to check the TheOutput for NULL.

    BUILD.

    8) go back to Form1
    9) Place MyUserControlWithButtons on the form, name it “mykeyboard”
    10) Place a TextBox on the form, name it “mytextbox”
    11) Go to the Form1’s code
    12) in te constructor, BELOW the “InitializeComponent”, asign the mytextbox to the TheOutput of mykeyboard

    And this is it. Now you can build it and run, and everything should be OK. Please not that whole code of the ‘keyboard’ is in the usercontrol. The form only has set it up to work with that textbox. On the second form you can do it in the same way: place keyboard, place textbox, setup the keyboard to write to that textbox and it will work the same.

    The Code:

    MyUserControlWithButtons.cs

    using System;
    using System.Windows.Forms;
    
    namespace ReusingUserControlsSample
    {
        public partial class MyUserControlWithButtons : UserControl
        {
            public MyUserControlWithButtons()
            {
                InitializeComponent();
            }
    
            public TextBox TheOutput { get; set; }
    
            private void btnLetterA_Click(object sender, EventArgs e)
            {
                TheOutput.Text += "A";
            }
    
            private void btnLetterB_Click(object sender, EventArgs e)
            {
                TheOutput.Text += "B";
            }
    
            private void btnLetterC_Click(object sender, EventArgs e)
            {
                TheOutput.Text += "C";
            }
        }
    }
    

    MyUserControlWithButtons.cs

    namespace ReusingUserControlsSample
    {
        partial class MyUserControlWithButtons
        {
            /// <summary> 
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.IContainer components = null;
    
            /// <summary> 
            /// Clean up any resources being used.
            /// </summary>
            /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }
    
            #region Component Designer generated code
    
            /// <summary> 
            /// Required method for Designer support - do not modify 
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                this.btnLetterA = new System.Windows.Forms.Button();
                this.btnLetterB = new System.Windows.Forms.Button();
                this.btnLetterC = new System.Windows.Forms.Button();
                this.SuspendLayout();
                // 
                // btnLetterA
                // 
                this.btnLetterA.Location = new System.Drawing.Point(3, 3);
                this.btnLetterA.Name = "btnLetterA";
                this.btnLetterA.Size = new System.Drawing.Size(66, 21);
                this.btnLetterA.TabIndex = 0;
                this.btnLetterA.Text = "The \"A\"";
                this.btnLetterA.UseVisualStyleBackColor = true;
                this.btnLetterA.Click += new System.EventHandler(this.btnLetterA_Click);
                // 
                // btnLetterB
                // 
                this.btnLetterB.Location = new System.Drawing.Point(66, 30);
                this.btnLetterB.Name = "btnLetterB";
                this.btnLetterB.Size = new System.Drawing.Size(66, 21);
                this.btnLetterB.TabIndex = 0;
                this.btnLetterB.Text = "The \"B\"";
                this.btnLetterB.UseVisualStyleBackColor = true;
                this.btnLetterB.Click += new System.EventHandler(this.btnLetterB_Click);
                // 
                // btnLetterC
                // 
                this.btnLetterC.Location = new System.Drawing.Point(3, 57);
                this.btnLetterC.Name = "btnLetterC";
                this.btnLetterC.Size = new System.Drawing.Size(66, 21);
                this.btnLetterC.TabIndex = 0;
                this.btnLetterC.Text = "The \"C\"";
                this.btnLetterC.UseVisualStyleBackColor = true;
                this.btnLetterC.Click += new System.EventHandler(this.btnLetterC_Click);
                // 
                // MyUserControlWithButtons
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.AutoSize = true;
                this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
                this.Controls.Add(this.btnLetterC);
                this.Controls.Add(this.btnLetterB);
                this.Controls.Add(this.btnLetterA);
                this.Name = "MyUserControlWithButtons";
                this.Size = new System.Drawing.Size(135, 81);
                this.ResumeLayout(false);
    
            }
    
            #endregion
    
            private System.Windows.Forms.Button btnLetterA;
            private System.Windows.Forms.Button btnLetterB;
            private System.Windows.Forms.Button btnLetterC;
        }
    }
    

    Form1.cs

    using System.Windows.Forms;
    
    namespace ReusingUserControlsSample
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                mykeyboard.TheOutput = mytextbox;
            }
        }
    }
    

    Form1.Designer.cs

    namespace ReusingUserControlsSample
    {
        partial class Form1
        {
            /// <summary>
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.IContainer components = null;
    
            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }
    
            #region Windows Form Designer generated code
    
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                this.mytextbox = new System.Windows.Forms.TextBox();
                this.mykeyboard = new ReusingUserControlsSample.MyUserControlWithButtons();
                this.SuspendLayout();
                // 
                // mytextbox
                // 
                this.mytextbox.Location = new System.Drawing.Point(84, 38);
                this.mytextbox.Name = "mytextbox";
                this.mytextbox.Size = new System.Drawing.Size(100, 20);
                this.mytextbox.TabIndex = 0;
                // 
                // mykeyboard
                // 
                this.mykeyboard.AutoSize = true;
                this.mykeyboard.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
                this.mykeyboard.Location = new System.Drawing.Point(66, 122);
                this.mykeyboard.Name = "mykeyboard";
                this.mykeyboard.Size = new System.Drawing.Size(135, 81);
                this.mykeyboard.TabIndex = 1;
                // 
                // Form1
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(284, 264);
                this.Controls.Add(this.mykeyboard);
                this.Controls.Add(this.mytextbox);
                this.Name = "Form1";
                this.Text = "Form1";
                this.ResumeLayout(false);
                this.PerformLayout();
    
            }
    
            #endregion
    
            private System.Windows.Forms.TextBox mytextbox;
            private MyUserControlWithButtons mykeyboard;
        }
    }
    

    Program.cs

    using System;
    using System.Windows.Forms;
    
    namespace ReusingUserControlsSample
    {
        static class Program
        {
            /// <summary>
            /// The main entry point for the application.
            /// </summary>
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1());
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two forms. The first form is the mainForm, this never goes anywhere.
I have two forms. The first form Main has 2 buttons and a link
i have two dropdown list. first drop down:1 enter code here <form:select path=custName id=custName>
I have a table inside a form. It has two columns, the first one
I have two forms. First one is to decide button numbers by using jslider.
I have two forms, first form contains the textbox and second form contains a
I have two forms using a ListView component. In the first form it works
I have two forms = Form1.CS and SMS.CS on the first form (Form1) i've
I have two forms. First one is to decide numbers of button by using
First thing, sorry for my English. I have two forms in index. Login form

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.