G
Guest
Hi,
Before I go into detail, is there any way to force a button to get that
dotted box on it that shows it's in focus? Just saying btn1.Focus(); isn't
working for me. Btn1 is definitely the thing being focused on, but you
wouldn't know by just looking at it. And it seems that the only way to get a
button to show highlight is to Tab into it.
So, the weird details...
Say I put a custom button on my form (and gave it tabstop 1). I then add a
textbox with tabstop 2. And finally another button (tabstop 3). If I click in
the textbox and press the Tab key, the 2nd button gets that dotted line, no
problem. Same goes if I press Shift-Tab (the 1st button shows focus). I made
the textbox so that it recognizes if the up or down keys are hit, so when I'm
in the textbox and press the up key, I say:
if (e.KeyCode == Keys.Up){SendKeys.Send("+{Tab}");}
and have no problem here either - the first button shows focus.
But if down is pressed:
if (e.KeyCode == Keys.Down){SendKeys.Send("{Tab}");}
it freaks out and everything freezes so that I have to open task manager to
close it down.
One other thing - if a button has been highlighted (tabbed into) once,
saying just btn1.Focus(); is enough. But, of course, I can't be sure that tab
will always be pressed.
Hope this makes sense.
Thanks for any help on this!
Mel
Before I go into detail, is there any way to force a button to get that
dotted box on it that shows it's in focus? Just saying btn1.Focus(); isn't
working for me. Btn1 is definitely the thing being focused on, but you
wouldn't know by just looking at it. And it seems that the only way to get a
button to show highlight is to Tab into it.
So, the weird details...
Say I put a custom button on my form (and gave it tabstop 1). I then add a
textbox with tabstop 2. And finally another button (tabstop 3). If I click in
the textbox and press the Tab key, the 2nd button gets that dotted line, no
problem. Same goes if I press Shift-Tab (the 1st button shows focus). I made
the textbox so that it recognizes if the up or down keys are hit, so when I'm
in the textbox and press the up key, I say:
if (e.KeyCode == Keys.Up){SendKeys.Send("+{Tab}");}
and have no problem here either - the first button shows focus.
But if down is pressed:
if (e.KeyCode == Keys.Down){SendKeys.Send("{Tab}");}
it freaks out and everything freezes so that I have to open task manager to
close it down.
One other thing - if a button has been highlighted (tabbed into) once,
saying just btn1.Focus(); is enough. But, of course, I can't be sure that tab
will always be pressed.
Hope this makes sense.
Thanks for any help on this!
Mel