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

Controlling one form from another form

P: n/a
In VB 6.0 I could control the properties of one form by
writing code in another form, something like this:

In the code of Form2 I would write Form1.Visible=True.

How can I do this in VB. NET?
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
>In VB 6.0 I could control the properties of one form by
writing code in another form, something like this:

In the code of Form2 I would write Form1.Visible=True.

How can I do this in VB. NET?


The second form needs to know about the instance of the original form.
Therefore create a Public Variable/Property of type of your original
form on the second form:

<code>
[Form1]
Private Sub SomeEvent(sender As Object, e As EventArgs)

Dim secondForm As New Form2
secondForm.OtherForm = Me
secondForm.Show

End Sub

[Form2]
Public OtherForm As Form

Private Sub SomeEvent(sender As Object, e As EventArgs)
'Do what you want eith OtherForm properties
OtherForm.BackColor = Color.Blue
End Sub
</code>

Hope this helps

Blu
Nov 20 '05 #2

P: n/a
Hi,

You need to keep a reference to the form to be able to modify it.
Here is a link to an article that show how to keep a forms collection.

http://msdn.microsoft.com/library/de...et05132003.asp

Ken
-------------------------------
"Robert" <an*******@discussions.microsoft.com> wrote in message
news:2e*****************************@phx.gbl...
In VB 6.0 I could control the properties of one form by
writing code in another form, something like this:

In the code of Form2 I would write Form1.Visible=True.

How can I do this in VB. NET?

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.