S
SJ
Hi all,
I have come across a weird problem when attempting to automatically
set the focus in a vb.net form to a checkbox control...
In my form I have (on a tab page in a tab control) several textboxes
and a checkbox. The behaviour I want from my app is as follows:-
When the textbox (which is prior in tab order to the tab control) has
been filled with a certain length of text by the user, the focus is
then automatically set to the checkbox.
The (basic) code I'm using in the textbox's key press event is :-
If int_NumCharsinTextBox > MaxAllowedLength Then
checkbox1.focus
End If
The bizarre thing is that this just does not work... UNLESS I have
pressed the tab key on the form first! Why is this? If I use above
code to set the focus to another text box instead of a checkbox, then
the focus goes there no problem with out having to press the tabkey
somewhere on the form.
Any points on how to overcome this problem will be gratefully
received. I'm going to be using this code in a few places and I would
like all the controls to behave in a consistent way.
Thanks in advance
Suzanne
I have come across a weird problem when attempting to automatically
set the focus in a vb.net form to a checkbox control...
In my form I have (on a tab page in a tab control) several textboxes
and a checkbox. The behaviour I want from my app is as follows:-
When the textbox (which is prior in tab order to the tab control) has
been filled with a certain length of text by the user, the focus is
then automatically set to the checkbox.
The (basic) code I'm using in the textbox's key press event is :-
If int_NumCharsinTextBox > MaxAllowedLength Then
checkbox1.focus
End If
The bizarre thing is that this just does not work... UNLESS I have
pressed the tab key on the form first! Why is this? If I use above
code to set the focus to another text box instead of a checkbox, then
the focus goes there no problem with out having to press the tabkey
somewhere on the form.
Any points on how to overcome this problem will be gratefully
received. I'm going to be using this code in a few places and I would
like all the controls to behave in a consistent way.
Thanks in advance
Suzanne