Click to See Complete Forum and Search --> : Set Focus in form_Load


ianhoc2
September 20th, 2002, 10:29 AM
I am trying to set the focus to textBox3 in the form_Load method - but the form's tab order says set the focus to textBox1. I do not want to change the tab order as this is a condtional move - Activate is not an option.
In VC++ there was an option to return TRUE/FALSE from OnInitDialog for just this purpose.
Any ideas?
Thanks
Ian

private void form_load(object sender, System.EventArgs e)
{
// textBox1 text entered by reading a file (if exists)

if (textBox1.Text != "")
{
textBox3.Focus();
}
} :mad:

ianhoc2
September 21st, 2002, 08:40 AM
Although not elegant, I can get this to work using Activated. The problem though is Activated is called everytime the window is minimized and then maximized (or hidden), and occasionally I have seen where it didn't work, presumably because Activated has been called before the fist system call to set focus to the lowest tab order control.

Doesn't anyone know the equivalent (if there is one!) to return false from OnInitDialog in VC++ ??

Thanks
Ian