Click here to Skip to main content
15,890,527 members
Home / Discussions / C#
   

C#

 
QuestionHow to paste only valid value in textbox. Pin
S a n d y5-Oct-08 22:03
S a n d y5-Oct-08 22:03 
AnswerRe: How to paste only valid value in textbox. Pin
Nagy Vilmos5-Oct-08 22:05
professionalNagy Vilmos5-Oct-08 22:05 
GeneralRe: How to paste only valid value in textbox. Pin
S a n d y5-Oct-08 22:09
S a n d y5-Oct-08 22:09 
GeneralRe: How to paste only valid value in textbox. Pin
N a v a n e e t h5-Oct-08 22:29
N a v a n e e t h5-Oct-08 22:29 
AnswerRe: How to paste only valid value in textbox. Pin
Vikram A Punathambekar5-Oct-08 22:33
Vikram A Punathambekar5-Oct-08 22:33 
AnswerRe: How to paste only valid value in textbox. Pin
DaveyM696-Oct-08 0:13
professionalDaveyM696-Oct-08 0:13 
GeneralRe: How to paste only valid value in textbox. Pin
S a n d y6-Oct-08 1:41
S a n d y6-Oct-08 1:41 
GeneralRe: How to paste only valid value in textbox. Pin
DaveyM696-Oct-08 2:02
professionalDaveyM696-Oct-08 2:02 
OK. This example creates a customized TextBox so add this class, build then drop onto a form.
public class RestrictedTextBox : TextBox
{
    private const int WM_PASTE = 0x0302;

    protected override void WndProc(ref Message m)
    {
        if (m.Msg == WM_PASTE)
        {
            if (!IsPasteValid())
            {
                m.Result = IntPtr.Zero;
                return;
            }
        }
        base.WndProc(ref m);
    }

    private bool IsPasteValid()
    {
        bool rtn = false;
        IDataObject obj = Clipboard.GetDataObject();
        string pasteString = (string)obj.GetData(typeof(string));
        // Do checks on pasteString here and set rtn to true if OK.
        return rtn;
    }
}


Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

GeneralRe: How to paste only valid value in textbox. Pin
S a n d y6-Oct-08 2:10
S a n d y6-Oct-08 2:10 
AnswerRe: How to paste only valid value in textbox. Pin
Vengatachalapathy Palanivel6-Oct-08 2:00
Vengatachalapathy Palanivel6-Oct-08 2:00 
GeneralRe: How to paste only valid value in textbox. Pin
S a n d y6-Oct-08 2:03
S a n d y6-Oct-08 2:03 
GeneralRe: How to paste only valid value in textbox. Pin
Vengatachalapathy Palanivel6-Oct-08 3:55
Vengatachalapathy Palanivel6-Oct-08 3:55 
GeneralRe: How to paste only valid value in textbox. Pin
S a n d y6-Oct-08 18:48
S a n d y6-Oct-08 18:48 
GeneralRe: How to paste only valid value in textbox. Pin
Vengatachalapathy Palanivel6-Oct-08 19:38
Vengatachalapathy Palanivel6-Oct-08 19:38 
QuestionHow Save and retrive Font in database Pin
sepel5-Oct-08 19:56
sepel5-Oct-08 19:56 
AnswerRe: How Save and retrive Font in database Pin
Guffa5-Oct-08 22:43
Guffa5-Oct-08 22:43 
GeneralRe: How Save and retrive Font in database Pin
sepel6-Oct-08 3:26
sepel6-Oct-08 3:26 
GeneralRe: How Save and retrive Font in database Pin
Lazy_Monk7-Oct-08 3:40
Lazy_Monk7-Oct-08 3:40 
GeneralRe: How Save and retrive Font in database Pin
sepel7-Oct-08 7:28
sepel7-Oct-08 7:28 
GeneralRe: How Save and retrive Font in database Pin
Guffa7-Oct-08 21:18
Guffa7-Oct-08 21:18 
GeneralRe: How Save and retrive Font in database Pin
Guffa7-Oct-08 21:23
Guffa7-Oct-08 21:23 
QuestionExcel Automation Problem Pin
DJ2455-Oct-08 19:32
DJ2455-Oct-08 19:32 
AnswerRe: Excel Automation Problem Pin
Ashfield5-Oct-08 21:18
Ashfield5-Oct-08 21:18 
Questionpassing variants from C# client to MFC Automation enabled app Pin
venkyhyd5-Oct-08 19:15
venkyhyd5-Oct-08 19:15 
AnswerRe: passing variants from C# client to MFC Automation enabled app Pin
venkyhyd6-Oct-08 17:20
venkyhyd6-Oct-08 17:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.