Results 1 to 10 of 10

Thread: 2 Forms

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2009
    Posts
    146

    2 Forms

    Hello, I have 2 forms inwhich they are both in the same position and always will be! I will not explain why but please can I just have a helping answer

    I want my form2 to always stay on-top of Form1 without having to have topmost on!

    Thanks, Help really Appreciated!

  2. #2
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: 2 Forms

    Here's the solution... of sorts... without TopMost

    vb.net Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         Dim tmr As New Timer
    3.         tmr.Interval = 20
    4.         AddHandler tmr.Tick, AddressOf tmr_Tick
    5.  
    6.     End Sub
    7.  
    8.     Private Sub tmr_Tick(ByVal sender As Object, ByVal e As EventArgs)
    9.         Me.BringToFront()
    10.     End Sub

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2009
    Posts
    146

    Re: 2 Forms

    Don't work.. Still Form1 is above Form2

    Notes:
    Form1.Opacity = 50

  4. #4
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    Re: 2 Forms

    Why try to re invent the wheel ¿

    The TopMost property is there for a reason. BringToFront is there for a reason. dcrew, you say you will not explain why you want to reinvent the wheel, unfortunately, you'll have to explain what you want ....
    VB.NET MVP 2008 - Present

  5. #5

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Nov 2009
    Posts
    146

    Re: 2 Forms

    No, There is no existing reason why i should. I think my only question was specifically 'I have 2 Forms, I want Form2 to be always ontop of Form1 without having to TopMost everything else' It's such a simple question and of matter there is'nt to as why you need to know why I want to do this. All I indeed need to know is the question inserted into ' tags above.

  7. #7

  8. #8
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    Re: 2 Forms

    OK, no need to be sarcastic, and attacking. I was saying that you are trying to reinvent the wheel for which there is no need. The TopMost property, as i said, has a specific function, which does what you want. If you don't want that, fine. If you want to reinvent the wheel, fine. If you don't want my advice, fine.
    VB.NET MVP 2008 - Present

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Nov 2009
    Posts
    146

    Re: 2 Forms

    As i have completed it now and made a timer called BtF

    Input Code
    vb Code:
    1. Me.BringToFront()

    Thanks, Cicatrix, HanneSThEGreaT

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

    Re: 2 Forms

    When you show Form2 from Form1, you simply pass in form1 instance as its owner:
    Code:
    'this code is in Form1
    Dim frm2 As New Form2()
    frm2.Show(Me)
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

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