Share via

Default clipboard text Paste key combination modication

rahul kumar 605 Reputation points
2023-10-06T22:02:39.42+00:00

Hello experts ,

Can the default behaviour of pasting text inside a textbox by using ctrl+v is changed by creating a usercontrol textbox . like if in my project , i want to modify it by creating a usercontrol textbox , what should i modify the code so that whenever i copy some text and trying to paste in this usercontrol textbox , the only keys allowed is something else like ctrl+alt+v .

Developer technologies | Windows Forms
Developer technologies | .NET | Other
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.


Answer accepted by question author

Castorix31 91,876 Reputation points
2023-10-07T08:40:37.46+00:00

You can disable WM_PASTE

A quick test in a User Control derived from TextBox :

        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case WM_PASTE:
                    {
                        Console.Beep(5000, 10);
                        return;
                    }
                    break;
            }
            base.WndProc(ref m);
        }


       public const int WM_PASTE = 0x0302;

Was this answer helpful?

1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. KOZ6.0 6,810 Reputation points
    2023-10-06T22:27:04.35+00:00

    Although it is possible, it is better not to do so because the user will not be able to operate it intuitively.

    Was this answer helpful?

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.