Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Setting focus on a field
Message
De
24/08/2010 21:35:44
 
 
À
24/08/2010 11:41:42
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01478155
Message ID:
01478281
Vues:
37
This message has been marked as the solution to the initial question of the thread.
Michel,

Normally, the Focus() method of a control is used to move the focus to that control:
private void MyButton_Click(object sender, System.EventArgs e)
{
    // Move the Focus elsewhere
    this.MySpecialTextBox.Focus();
}
This works at any time, except during Form/Control Load. Then, you simply have to
set the ActiveControl:
private void MyForm_Load(object sender, System.EventArgs e)
{
    // Start the Form with the Focus on a certain control
    this.ActiveControl = this.MySpecialTextBox;
}
~~Bonnie





>This used to work until recently. Basically, the last line of the form .Load() event used to set the focus on the first control:
>
>
>' Set the focus to the first field
>ActivationCode.Focus()
>
>
>But, I added more lines in the form Load() event and I thought this was a factor. So, I removed them all and only kept that line. It still doesn't work. Anyone could see what could be a factor here?
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform