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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:44:41+00:00 2026-05-28T14:44:41+00:00

I have a .net application which includes search screen which has a panel with

  • 0

I have a .net application which includes search screen which has a panel with has three text boxes, each with a varying character lengths.

What I’d like to do is capture when the paste command when invoked from the first box and paste my clipboard into the three boxes.

This functionality is similar to many modern applications accepting input for serial keys and phone numbers.

  • 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-28T14:44:42+00:00Added an answer on May 28, 2026 at 2:44 pm

    As far as I can find there is no other sensible way of doing this than to capture the WM_PASTE event.

    Derive a class from TexBox and implement this method:

    using System.Windows.Forms;
    using System.ComponentModel;
    
    class TextBoxWithOnPaste : TextBox
    {
    
        public delegate void PastedEventHandler();
    
        [Category("Action")]
        [Description("Fires when text from the clipboard is pasted.")]
        public event PastedEventHandler OnPaste;
    
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == 0x302 && OnPaste != null) // process WM_PASTE only if the event has been subscribed to
            {
                OnPaste();
            }
            else
            {
                base.WndProc(ref m);
            }
        }
    }
    

    Then put three of those custom controls on your form, and assign the OnPaste event on all three textboxes to the same method, in this case I called it textPasted():

    private void textPasted()
    {
        String input = Clipboard.GetText();
    
        int l1 = textBoxWithOnPaste1.MaxLength;
        int l2 = textBoxWithOnPaste2.MaxLength;
        int l3 = textBoxWithOnPaste3.MaxLength;
    
        try
        {
            textBoxWithOnPaste1.Text = input.Substring(0, l1);
            textBoxWithOnPaste2.Text = input.Substring(l1, l2);
            textBoxWithOnPaste3.Text = input.Substring(l2, l3);
        }
        catch (Exception)
        { }
    
    }
    

    Since you implied “like a serial”, I guessed you want the pasted string to be split among the textboxes. The code above is not perfect for that (try pasting a single space into the third text box after entering data manually in all three, so it would be nice if you knew in which textbox the text was pasted, for example by altering the event’s parameters and that way sending the sender with it), but it basically works and I guess you can figure out the rest (you could use the Tag property to identify the textbox).

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

Sidebar

Related Questions

I have a ASP.NET web application which has more than 100 pages. Each page
I have a asp.net web application which has a number of versions deployed on
I have an ASP.NET application which features some server-side includes. For example: <!--#include virtual=/scripts.inc
I have a .NET application which serializes an object in binary format. this object
I have an .Net MVC application which runs fine if I use the build
I have an ASP.Net application which as desired feature, users would like to be
I have a .net client application which is connected to a remote database. Is
I have an ASP.net application which returns a binary PDF file (stored from the
I have an ASP.NET MVC-application which I want deployable on both IIS6 and IIS7
We have a .NET 2.0 application which we normally run on IIS6, and used

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.