CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2002
    Location
    Ohio, USA
    Posts
    5

    Question Set Focus in form_Load

    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();
    }
    }

  2. #2
    Join Date
    Sep 2002
    Location
    Ohio, USA
    Posts
    5

    Red face

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured