void Form1::textBox9_KeyPress(System::Object^  sender, System::Windows::Forms::KeyPressEventArgs^  e)
{
	if(!Char::IsDigit(e->KeyChar) && (e->KeyChar != 0x08))
        e->Handled = true;
}

Thats the code i got, but, how could i allow CTRL+V.

if(Char::IsDigit(e->KeyChar))
    return;
    if(e->KeyChar=='\b')
    return;
    if(e->KeyChar=='\v')
    return;
    if(e->KeyChar=='CTRL')
    return;
    e->Handled=true;

This also doesn't work ._.

(Im using Visual Studio 2010)

Recommended Answers

All 4 Replies

If you enter ^v or backspace, you can display the integer value of the keys to find out what to compare the key value to.

Could anyone post code snippet, please ?

I tryed much differnt things, but they all didnt worked.

The hex value for ctrl+v is 0x16.Try that in line 7.More here
http://www.pcguide.com/res/tablesASCII-c.html

Thank you for you help :)

if(Char::IsDigit(e->KeyChar))
    return;
    if(e->KeyChar=='\b')
    return;
    if(e->KeyChar==(0x16))
    return;
    e->Handled=true;

This worked :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.