locked
Lock And Unlock Form

    Question

  • I have one form and i call out another form from there, i am able to set focus on that form but i want to lock the other form. Only user close the second form then only the previous form can be unlocked. May i know how to do it? Thank you
    Sunday, January 28, 2007 7:27 AM

All replies

  • Sunday, January 28, 2007 7:41 AM
  • its a simple as showing the second form using the

    dim x as new form2
    x.showdialog

    Instead of

    Dim x as new form2
    x.Show

     

    Try using both of them an calling from an instance of form1 and seeing the difference.

     

    Thursday, February 01, 2007 1:39 AM
  • I want to pop out the form1 using dialogbox because i want the focus always on the form1 unless they close it. I use the following code but it shows two form under the taskbar and is there any way for me to display the dialogbox with one taskbar form. Thank you.
     

    Dim DisplayForm As New form1

    form1.ShowDialog()

    Thursday, February 01, 2007 1:39 AM
  • Try setting the TopMost property to true.

     

    Thursday, February 01, 2007 1:50 AM
  • Sorry, mistyped the code, actually i made use of

    Dim DisplayForm As New form2

    DisplayForm.ShowDialog()

    and it still don't work as my requirement. It did pop out the dialogbox but how to make the two taskbar forms to become one? Thank you.

     

     

    Thursday, February 01, 2007 4:15 AM
  • There is a potentially easy way round the problem. Show the second form modally (a concept you'll be familiar with from VB.OLD, I'm sure). The .NET syntax is:-

    Private Sub ShowForm2Button_Click(ByVal sender As System.Object_
        ByVal e As System.EventArgsHandles ShowForm2Button.Click
        Dim F2 As New Form2()
        F2.ShowDialog(Me)
    End Sub

    Now, as you'd expect, the user can't get focus back to Form1 to click that pesky button again until they've closed down this instance of Form2.

    Thursday, February 01, 2007 7:55 AM
  • I think lucerias wants there to be no taskbarbutton for the modal form, so try this (with wei82's example):

    Private Sub ShowForm2Button_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles ShowForm2Button.Click
                 Dim F2 As New Form2()
                 F2.ShowInTaskbar = False
                 F2.ShowDialog(Me)
    End Sub

    Thursday, February 01, 2007 8:33 AM
  • Is it possible to show the DialogBox and specify it is under one parent as child form at the same time? If it is possible, any one can show the sample code? Thank you.
    Friday, February 02, 2007 12:59 AM