Problem setting focus to specific control from form load event 
Author Message
 Problem setting focus to specific control from form load event

I'm trying to set the focus to a specific control in the form's load event,
but it seems to be ignoring the command.  The form has four or five
textbox's and the tab order was set at design time.  At run time if I can
get the values for the first two textboxes from the registry I want to set
the focus to the third textbox.

I've tested the return value from the statement: myTextBox.Focus() and it
returns FALSE.  I've added a command button and coded the clicked event with
the same command and it works fine.  Is there some problem with using the
load event, i.e. the form is not visible so focus can not be set?  If that
is true is there a way to do this after the form loads?  The form in
question is a modal form so I don't have direct access to the forms
properties after it is displayed.

Also is there any way to "Post" a command, i.e. put a command in the Event
Que or Command Que?

TIA,

James Knowlton



Fri, 08 Oct 2004 10:46:06 GMT  
 Problem setting focus to specific control from form load event
Try using the InitializeComponent routine
Mike MCP


Quote:
> I'm trying to set the focus to a specific control in the form's load
event,
> but it seems to be ignoring the command.  The form has four or five
> textbox's and the tab order was set at design time.  At run time if I can
> get the values for the first two textboxes from the registry I want to set
> the focus to the third textbox.

> I've tested the return value from the statement: myTextBox.Focus() and it
> returns FALSE.  I've added a command button and coded the clicked event
with
> the same command and it works fine.  Is there some problem with using the
> load event, i.e. the form is not visible so focus can not be set?  If that
> is true is there a way to do this after the form loads?  The form in
> question is a modal form so I don't have direct access to the forms
> properties after it is displayed.

> Also is there any way to "Post" a command, i.e. put a command in the Event
> Que or Command Que?

> TIA,

> James Knowlton



Sat, 09 Oct 2004 19:59:57 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Not possible to set the focus to a TextBox while the form is loading

2. passing forms and controls so I can set focus back to a form from a module

3. passing forms and controls so I can set focus back to a form from a module

4. How to Set Focus on specific field in Outlook

5. set the focus on a specific fame

6. Set focus on a specific record in a msflexgrid after a it has been populated

7. set the focus on a specific fame

8. MDI child forms and control lost-focus events

9. KeyDown Event of Form Not working when Datacombo Control got focus

10. Filter by form - how to set focus on a control

11. Form close event occurs before lost focus event

12. DHTMLEDIT control event and focus problems

 

 
Powered by phpBB® Forum Software