0

I have 10 TextBox's in a GroupBox, in a Tab control. How do I implement Cut, Copy & Paste on all of the TextBox's without accessing each one individually?

Sachin Kainth
  • 45,256
  • 81
  • 201
  • 304
robblot
  • 395
  • 2
  • 5
  • 15

1 Answers1

0

Just use a custom text box that blocks or replaces the cut, copy, paste command:

public class MyTextBox : TextBox
{
    private const int WM_CUT   = 0x0300;
    private const int WM_COPY  = 0x0301;
    private const int WM_PASTE = 0x0302;

    protected override void WndProc(ref Message m)
    {
        switch(m.Msg)
        {
            case WM_CUT:
                // Handle Cut
                return;

            case WM_COPY:  
                // handle copy 
                return;

            case WM_PASTE:
                // handle paste
                return;
        }

        base.WndProc(ref m);
    }
}
John Arlen
  • 6,539
  • 2
  • 33
  • 42