Click to See Complete Forum and Search --> : Handle textbox's event by the form


Fazal Khan
September 30th, 2005, 04:41 AM
Hi,
I have a problem with event handling.

I have a Form and one textbox drawn on the form. I want to handle the keypress event of textbox as follows:

whenever I press normal keys like a-z or 0-9 then event occurred on textbox, if I press other than these keys event should be passed to the form.

I hope Ihave explained my problem.

If any soln. plz help me.

Thanks in advance.

Bill Crawley
September 30th, 2005, 04:49 AM
textbox_keypress....

if (keyascii is within your range) then
.........
else
form_keypress (or which ever event you want to run)

end if

Fazal Khan
October 1st, 2005, 03:49 AM
Hi,

Above code may work properly but on every text box i will have to write this code.

Actually my need is diffrent.

I want to make our own shorcut keys like Alt+A. If focus is on text box then every event occured on text box. I want to capture all the keys event other than A-Z n 0-9. if user press any key, other than these key. then Form's event should be occured.

thats it.

jmcilhinney
October 1st, 2005, 07:46 AM
Set the KeyPreview property of the form to True and create an event handler for both the form and the TextBox. Then you just test for the specific keys that you want each to handle. Note that the form will receive the event first.

Fazal Khan
October 5th, 2005, 03:44 AM
I will see it. if success then thanks.

Fazal Khan
October 5th, 2005, 04:00 AM
It's work, Thanks a lot.