Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
FocusOnLoadControl and mmBaseForm.SetFocus
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Versions des environnements
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01079869
Message ID:
01080245
Vues:
20
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform