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. =(
>>