Are there some ways to check charater in clipboard only digit before paste into textbox C# (Both Ctrl+V and right click -> Paste), which not using MarkedTextbox.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Carriage Return (ASCII chr 13) is missing from tex
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
I ~think~ you want a TextBox that can only accept digits?
If yes, then set the ES_NUMBER style on the TextBox via SetWindowLong():
Alternatively, you can Inherit from TextBox and set ES_NUMBER in CreateParams():
Add rule in textbox text change to accept number only like:
If you literally want to only allow pastes that have digits only, then Inherit from TextBox and trap WM_PASTE, suppressing the message when desired:
I doubt there are anyways to check before pasting to TextBox, I would suggest subscribing to
KeyDown
andMouseClick
events, and writing your own logic.You can get help from MSDN on how to read/write clipboard content.