By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 1,534 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

Pass values to existing open form

P: 64
Hi all,

I am using two forms.From form1 button click i am opening form2,and i am passing values to form2 using delegate.when i click the button again form2 shouldn't open again but values should pass to already open form(form2) here i am added tab pages in tab control for every button click in one form.

how to do this...anyone help me...thnax in advance

Expand|Select|Wrap|Line Numbers
  1.  
  2. Form1 Code:
  3.  
  4. Dim frm As Form
  5.  
  6.             For Each frm In My.Application.OpenForms
  7.  
  8.                 Dim x1 As String = frm.ToString()
  9.                 Dim x2 As String = My.Forms.Form2.ToString()
  10.                 If x1 = x2 Then
  11.  
  12.                     MessageBox.Show("visible")
  13.  
  14.                     Exit Sub
  15.                 End If
  16.             Next
  17.  
  18.             im = New Form2 
  19.             im.Show()
  20.             Dim MyGreeting As GreetingDelegate
  21.             MyGreeting = New GreetingDelegate(AddressOf im.GoodMoring)
  22.             MyGreeting.Invoke(Textbox1.Text, Textbox2.Text)
  23.  
  24. Form2 Code:
  25. Public Sub GoodMoring(ByVal Fname As String, ByVal Username As String)
  26.             _strfriendname = Fname
  27.             _strUsername = Username
  28.             Dim wbReceive As New WebBrowser
  29.             Me.ctlTabPages.Add(New TabPages.TabPage(_strfriendname, wbReceive, "Created: " & DateTime.Now.ToLongTimeString()))
  30.         End Sub
  31.  
Nov 28 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.