• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 279
  • Last Modified:

VB.net Form Problem

'MY problem is related VB.Net Form ( i m new in .Net)

'In my application i have 2 form ( formA and formB)
'now on form A i have one command button and i am calling formB ,FormB also conatin One command button
'now when i calling formB then it should be on top of screen even i open some anoher application (eg. MS Word )
'the FormB is Top of screen but not as Modal form ( in sort i allow to work in word)
'Question :- How its possible to do this ??

'Now Suppose i am in MSWord and i click on that my formB command button then formB should be close and and
'return on formA

'how can i able to change the property of formA controls form formB suppose forma.text1.text = "hi" form formB

Hope immediate advice
thanks
0
vsvb
Asked:
vsvb
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Many ways to go about this...

Public Class formA
    Inherits System.Windows.Forms.Form

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim b As New formB
        b.Tag = Me ' store reference to this form
        b.TopMost = True ' keep formB on top of other apps
        ' trap when formB is closed
        AddHandler b.Closed, AddressOf Me.b_Closed
        b.Show()
    End Sub

    Private Sub b_Closed(ByVal sender As Object, ByVal e As System.EventArgs)
        Me.Activate() ' show this form when formB is closed
        If Me.WindowState = FormWindowState.Minimized Then
            Me.WindowState = FormWindowState.Normal
        End If
    End Sub
End Class


Public Class formB
    Inherits System.Windows.Forms.Form

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim a As formA = CType(Me.Tag, formA)
        a.TextBox1.Text = "hi" ' change formA from within formB
        Me.Close()
    End Sub
End Class

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now