Results 1 to 4 of 4

Thread: [RESOLVED] [2005] Giving a form focus

  1. #1

    Thread Starter
    Hyperactive Member Troy Lundin's Avatar
    Join Date
    May 2006
    Posts
    489

    Resolved [RESOLVED] [2005] Giving a form focus

    I am showing a form with Form.Show and I write a few lines to a textbox on the form with TextBox.AppendText.

    While I write the text I am performing a couple small functions on my main form, then I update the textbox. Kind of like a verbose progress dialog.

    When the process is done I try to give the textbox focus by using Form.Focus then TextBox.Focus. But the form does not get focus, I can tell this because the toolbar icon for the form does not become depressed (as it would if it had focus.)

    So, what am I doing wrong. I assumed the Focus method would give the form focus. That's a pretty safe assumption. So, what is the method that does actually give the form focus.
    Prefix has no suffix, but suffix has a prefix.

  2. #2
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Re: [2005] Giving a form focus

    Try
    vb Code:
    1. Me.Activate()

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] Giving a form focus

    Well Troy, you've told me before not to assume that you haven't read the relevant MSDN documentation, yet the following quote can be found by reading the documentation for the Focus method of the Form class:
    Focus is a low-level method intended primarily for custom control authors. Instead, application programmers should use the Select method or the ActiveControl property for child controls, or the Activate method for forms.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Hyperactive Member Troy Lundin's Avatar
    Join Date
    May 2006
    Posts
    489

    Re: [2005] Giving a form focus

    Touche.
    Prefix has no suffix, but suffix has a prefix.

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