Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
FocusOnLoadControl and mmBaseForm.SetFocus
Message
 
To
21/12/2005 10:25:03
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01079869
Message ID:
01080245
Views:
22
This message has been marked as the solution to the initial question of the thread.
Andrew,

>I'm using MM v. 1.4.1 with Infragistics controls but the problem has been reproduced using plain MM controls.
>
>I'm having some problems with setting focus on a control when a form loads. The control that I want to get the focus on form load does not get it if I use the SetFocus method (called from my bizForm's Load event) or set the FocusOnLoadControl.

I've been stewing on this one for a while and have finally come up with a solution. For some reason the SetFocus() method works great at any other time but form load. To get a control to have focus at form load you need to use the form's ActiveControl property like this:
Form ParentForm = mmAppDesktop.FormMgr.GetParentForm(this.FocusOnLoadControl);
ParentForm.ActiveControl = this.FocusOnLoadControl;
ParentForm.ActiveControl.Focus();
I have added a new overload of SetFocus() to mmBaseForm that allows you to specify if you are setting focus during form load. If so, it uses this new methodology. Otherwise it uses the standard method.

For now you can put this code in your application form's load (remember to check if FocusOnLoadControl is null).

Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform