简体   繁体   中英

Pop up User Control in a new Windows Form C#

Any help will do!

I have a C# GUI which contain a User Control, this User Control contains a web browser, I want to make a button which will make it pop in a new window in the current state it is in.

Lets say I have the web browser opened on a specific page in Google, and I want to pop up the User Control in a new Windows Form at the same state and not as a new window that will take me to google.com but to the current page I had open.

Is there anyway to make it work?

Thanks in advance

Here is what you can do.

a) Access the UserControl class from the parent forms class.

b) Create a internal property in user control class that will return your WebBrowser control object.

c) From the main form you can then access WebBrowser.Url property and you either save this URL, redirect the browser or save the URL to show the user control later with the same URL. If you assign a string to this Url property it will navigate the browser to that page.

Please read this WebBrowser.Url MSDN

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM