Accessing a web form control from a different web forms code behind.

I am new to Winform programming and need help figuring something out.

Basically I have two winforms in my project(Winform1 and Winform2).
The first one has a button control on it. The second has a WebBrowser control on it.
The control is named "webBrowser1"
 

When the button on the first Windows form is pressed, in the code behind for that button,
I want to display the second web form which has the WebBrowser control on it. Before
I display it though, I need to access the WebBrowser control and set the URL for it.
So my question is how do I access the WebBrowser control from the code behind of the first web form.

This is as far as I got:


// Button click event for Form1
private void button1_Click(object sender, EventArgs e)
{

   Form2 frm = new Form2();
   // Now how do I access the control webBrowser1 and set the URL for it?
   



   frm.ShowDialog();

}
LVL 2
brgdotnetcontractorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

haxkmavCommented:
Hi,

Form2 frm=new Form2();
WebBrowser web=(WebBrowser)frm.Controls["webBrowser1"]
web. ...

frm.ShowDialog();

This will work for you, just replace the name in the quotes with your web browser control name.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
brgdotnetcontractorAuthor Commented:
Special thanks, it worked great.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.