Intercept Paste on TextBox control

  • Thread starter Thread starter Radovan Radic
  • Start date Start date
R

Radovan Radic

Hello all,

I am new to .NET and a i am moving from Delphi (finally!) to C#.
Now, i am trying to develop custom TextBox for numeric input. I have done it
almost, now i need to prevent paste so someone couldnt paste letters into
numeric text box. How this can be done in C#? In Delphi there was method to
implement methods wiht message code WM_PASTE, and within that method i could
control the contents of the pasted text.

Thanks.
Radovan
 
To intercept messages in textbox control, derive a class from TexBox and
implement

protected override void WndProc(ref Message m)
{
case 0x302: //WM_PASTE
{
}
base.WndProc(ref m)
}
 
To intercept messages in textbox control, derive a class from TexBox and
implement

protected override void WndProc(ref Message m)
{
switch(m.Msg)
{
case 0x302: //WM_PASTE
{
}
default:
base.WndProc(ref m)
}
}
 
Back
Top