dcsimg
Results 1 to 8 of 8

Thread: Strange Problem of Focus in forms

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,133

    Strange Problem of Focus in forms

    I have 3 Forms
    1) Main Form
    2) Sales List Form
    3) Sales Entry Form

    From the menu in the MainForm the user opens the SalesList form, in the SLF there is an dgv , on dblclicking the dgv the SalesEntry form is opened

    (I am showing an Messagebox in SalesEntry Form to confirm the form closure when the Close Button is pressed (not the x button))

    Now From the SalesList form..
    1) If i open the SalesEntry using ShowDialog , when the SalesEntry form closes the focus is set back to SalesList form, (normal behavior)

    2) if i open the SalesEntry form using Show,
    .....a) If i show the Closure confirmation msgbox..the focus is set to the mainform
    .....b) if i dont show the confirmation msgbox...the focus is set to saleslist form


    plz help with the second situation...i dont wish to use ShowDialog.


    PS:
    Contra to my post...i have tried to recreate the situation in another Solution, everything works fine(in all cases),

    i am not able to find the problem in my current project

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,455

    Re: Strange Problem of Focus in forms

    Can't you use saleslist.BringToFront() after the msgbox?

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,455

    Re: Strange Problem of Focus in forms

    It's a problem with modality and non-modality. A form opened with showdialog and also any msgbox are modal forms. Forms opened with show are non modal, with the exception of MessageBox.Show

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    34,058

    Re: Strange Problem of Focus in forms

    I'm not sure what the problem really is. You mentioned what happened with ShowDialog, and two different behaviors with Show. The second behavior with Show appears to be the same as the behavior with ShowDialog, as far as which form gets focus. Since you say you don't want to use ShowDialog, then I would assume that the behavior you want is that which you get with ShowDialog...and you'd like the same behavior with Show. That's what has me puzzled, because it looks like you ARE getting that behavior with Show as long as there isn't a messagebox in the form close.

    If that's the case, then don't use a messagebox in close. What good does that do? What role is it supposed to play?

    Sure, it's a strange work around that doesn't explain the underlying problem, but it kind of seems like it would be better.
    My usual boring signature: Nothing

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,455

    Re: Strange Problem of Focus in forms

    Quote Originally Posted by Shaggy Hiker View Post
    I'm not sure what the problem really is. You mentioned what happened with ShowDialog, and two different behaviors with Show. The second behavior with Show appears to be the same as the behavior with ShowDialog, as far as which form gets focus. Since you say you don't want to use ShowDialog, then I would assume that the behavior you want is that which you get with ShowDialog...and you'd like the same behavior with Show. That's what has me puzzled, because it looks like you ARE getting that behavior with Show as long as there isn't a messagebox in the form close.

    If that's the case, then don't use a messagebox in close. What good does that do? What role is it supposed to play?

    Sure, it's a strange work around that doesn't explain the underlying problem, but it kind of seems like it would be better.
    Isn't the msgbox there to confirm closing?

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,133

    Re: Strange Problem of Focus in forms

    Can't you use saleslist.BringToFront() after the msgbox?
    I am not using the Default instance of the form.
    I am opening it as

    Dim slf as New SalesList()
    slf.show()

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,133

    Re: Strange Problem of Focus in forms

    Quote Originally Posted by .paul. View Post
    Isn't the msgbox there to confirm closing?
    Yes..its is

  8. #8
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,455

    Re: Strange Problem of Focus in forms

    Quote Originally Posted by aashish_9601 View Post
    I am not using the Default instance of the form.
    I am opening it as

    Dim slf as New SalesList()
    slf.show()
    You need to either pass a reference to the instance, to every form that might need it, or use a global module to declare global variables

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width