Access key in C# application dont work

T

tasiekk

I have 1 lil problem. I make simple Win Forms app and i put there a tab
control. There i make two pages. In each page i make 1 button. In
tabpage1 button1 and in tabpage2 button2. And i make access key for
both buttons. &button1 and &button2. They have same access key but they
are in diffrent pages. Access key works only in tabpage1 for button1
and access key for second button dont work. BUT! in diffrent comp it
works. Same exec run on mine comp dont work and in another comp it
works. Any1 know whats wrong?
I ll be greatfull for any advices.

Jarek
 
K

Kevin Spencer

Use the Form's KeyPreview property to allow the Form "1st look" at the key
being pressed. Create an Event Handler for the KeyDownEvent, and have the
Form handle it. If it is the access key for the 2 buttons, use the
PerformClick method of the key that is in the currently-visible tab. Then
set the Handled property of the KeyEventArgs to true to prevent the event
from propogating to the child Controls.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

If the truth hurts, wear it.
 
T

tasiekk

it is realy werid solution. Same code - my simple solution works in
other comps, no need to change anything in code. i need solution abt
.... dunno versions, frameworks, whatever but this code works good but
not in mine comp :/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top