Results 1 to 5 of 5

Thread: is there a way to make another form, that is created by the main form, to be topmost?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,168

    is there a way to make another form, that is created by the main form, to be topmost?

    I tried setting ".topmost" property to true, but it becomes top most for all the application in windows. I just want the "secondary" form to be topmost on the main form.

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: is there a way to make another form, that is created by the main form, to be topmost?

    Try setting the "StartupPosition" property to center parent
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3
    New Member Ratus Norvegicus's Avatar
    Join Date
    May 2006
    Location
    Derbyshire, England
    Posts
    4

    Re: is there a way to make another form, that is created by the main form, to be topmost?

    you could use .ShowDialog(); so that the form you show doesn't hide behind your other form ( s ) , or .BringToFront(); after showing your form using .Show(); , but the later will allow your new form to hide behind your other forms.
    alternatively you could use mdi.
    walking on the beaches, looking at the peaches

  4. #4
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: is there a way to make another form, that is created by the main form, to be topmost?

    Or you could use ShowDialog(ParentForm);
    this will disable (and move back) the parent form until the child form is closed
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

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

    Re: is there a way to make another form, that is created by the main form, to be topm

    Do you want this child form to be modal (prevent access to the parent while it's open) like a MessageBox or modeless (allow access to the parent but remain on top) like the Visual Studio Find and Replace dialogue?

    If you want it modal then you can simply call ShowDialog. There is no need, or point, to passing the parent form as an argument unless you want to be able to access the parent in code from the child.

    If you want it to be modeless then you call Show but you pass the parent form as an argument. This makes the child an owned form of the parent. Owned forms will always appear on top of their owner without prevent access to it. They will also be minimised, restored and closed along with their owner. You can also create an owned form by setting the child form's Owner property or calling the parent form's AddOwnedForm method.
    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

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