473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Intercept Paste on TextBox control

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
Nov 16 '05 #1
3 15241
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)
}

--
Shak
(Houston)


"Radovan Radic" <ra****@eunet.yu> wrote in message
news:ui**************@TK2MSFTNGP09.phx.gbl...
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

Nov 16 '05 #2
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)
}
}

--
Shak
(Houston)
"Radovan Radic" <ra****@eunet.yu> wrote in message
news:ui**************@TK2MSFTNGP09.phx.gbl...
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

Nov 16 '05 #3
Thanx a lot Shakir, i appreciate your help.

Radovan

"Shakir Hussain" <sh**@fakedomain.com> wrote in message
news:uC**************@TK2MSFTNGP11.phx.gbl...
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)
}
}

--
Shak
(Houston)
"Radovan Radic" <ra****@eunet.yu> wrote in message
news:ui**************@TK2MSFTNGP09.phx.gbl...
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


Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: VitoriaTang | last post by:
I want to know how to capture the paste message. I tried to capture the WM_PASTE, but it seems as the richtextbox doedn't send this message. But in fact, I can find the textbox will send paste...
9
by: Dan K. | last post by:
Hi Folks, Problem is, that on one of my controls the DEL key wont work in textboxes. i have different controls of this kind in my app and this is the only one the DEL Key wont do his job....
4
by: Legendary Pansy | last post by:
I was checking out the 101 C# Samples, specifically Windows Forms - Use the Clipboard. I took a look at the code for a while, and I understand what the program is doing with the cut, copy, pasting...
13
by: John | last post by:
Hi How can I implement cut or copy or paste in code? Thanks Regards
0
by: Stefan De Schepper | last post by:
Dear NG, I created a gridlike usercontrol. When clicking on a cell a textbox (or other control, depending on the cell's editortype) is shown. When some other control gets the focus, the textbox...
17
by: Steve | last post by:
I'm trying to code cut, copy, and paste in vb 2005 so that when the user clicks on a toolbar button, the cut/copy/paste will work with whatever textbox the cursor is current located in (I have...
3
by: Simon Verona | last post by:
Sorry for the repost, but this group seems to be more "active" than the group that I posted my question, and it's probably as valid here as there! I have a usercontrol, which contains a textbox...
11
by: John | last post by:
Hi In a winform app I need to provide a menu with Cut, Copy and Paste options., What code do I use to accomplish cut, copy and paste features for fields on a winfrom? Thanks Regards
8
by: jh | last post by:
I'd like to copy/paste into a listbox during runtime. I can do this for a textbox but can't figure out how to accomplish this for a listbox. Any help? Thanks.
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.