Results 1 to 3 of 3

Thread: [02/03] Form Focus issue with VB NET 2003

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    2

    Lightbulb [02/03] Form Focus issue with VB NET 2003

    G'day everyone,

    I've been fiddling, trying to do something with forms, but it just isnt working, so I wondered if anyone from this forum can help:

    What i have, is a button that when clicked, brings up a second form over the top of the current form (the old form is not hidden).

    At the moment, this new form loses focus, it dissappears and the user is left with just the first form, only its for some reason in its minimize state.

    Does anyone know what code i can put in to make the original form "pop up" so the user doesnt have to click down on the task bar to retrieve it?

    Any help would be muchly appreciated.

    Ta,

    Axel

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [02/03] Form Focus issue with VB NET 2003

    You can use ShowDialog on the 2nd form... If that is not what you want, then you can try to use BringToFront on the 2nd form after showing it.
    VB Code:
    1. Dim frm2 As new Form2
    2. frm2.Show()
    3. frm2.BringToFront()

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    2

    Re: [02/03] Form Focus issue with VB NET 2003

    wow, that was quick, thanks for the reply.

    I put that code into the second form under Form_Deactivate (is this when it loses focus? I tried Lost_Focus but it wasnt working).

    I didnt want the form to reload, so i took the "new" out that you suggested.

    VB Code:
    1. Dim frm2 As Form2
    2. frm2.Show()
    3. frm2.BringToFront()

    It gave me this error message:

    VB Code:
    1. An unhandled exception of type 'System.NullReferenceException' occurred in Subject Selector.exe
    2.  
    3. Additional information: Object reference not set to an instance of an object.

    and it highlights this: frm2.Show()

    (I've renamed the form back to frm2 so it makes sense in relation to the reply you gave me)

    Just incase i didnt explain right what im after ( i didnt think i didnt):
    When the second form is lost focus (like, by clicking on the form underneath it) I want that original form to be on top. But at the moment when i click it, it goes minimized or something. I want it to flash like msn windows do and pop-up straight away.. if thats possible

    Thanks again for the help, i hope that makes it a little clearer

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