Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Migrating from VFP
Message
De
07/06/2005 15:08:34
 
 
À
07/06/2005 14:46:27
Joel Leach
Memorial Business Systems, Inc.
Tennessie, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB.NET 1.1
Database:
MS SQL Server
Divers
Thread ID:
01020958
Message ID:
01021063
Vues:
24
Hi Joel,

>Interesting. In VFP, the form controls would be available in the form Init(). That's not the case in a WinForm constructor?<

They're available in the constructor (after the call to InitializeComponent()), but setting the Focus to a control in either the constructor or the Load event handler doesn't do any good.

~~Bonnie




>
>>1) A good place to put the code to call your Control.Focus() method is in the Form's Paint event handler. However, it will re-set focus to this control every time the form is repainted, which I don't think you want to do. The way around that is to either set a flag indicating the first time the Form is painted, or unhook the event handler after the first time you call it (which is what I prefer to do). Something like this (sorry ... =) this is C# ... the VB syntax for EventHandlers and Delegates is quite a bit different, and I'm not sure how to code it ... you'll have to figure it out.):
>>
>>// In your Form's constructor
>>this.Paint += new PaintEventHandler(Form1_Paint);
>>
>>// Then, the EventHandler itself
>>private void Form1_Paint(object sender, PaintEventArgs e)
>>{
>>	this.txtDescription.Focus();
>>	this.Paint -= new PaintEventHandler(Form1_Paint);
>>}
>>
>>The "+=" sets up the event handler to listen for the event and the "-=" unhooks it. Bottom line is that the Paint event handler is only invoked once, when the Form is first painted. Not sure how to do it in VB, sorry. =(
>>
Bonnie Berent DeWitt
NET/C# MVP since 2003

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

Click here to load this message in the networking platform