Embed the Internet explorer browser in a form using c #? [closed]

-5

I'm trying to get the browser into a form but there's no way someone tells me how to do it. I'm new in this language:

c #

 public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();

        WebBrowser web = new WebBrowser();
        web.Navigate("https://www.google.es/");

    }

    private void Form1_Load(object sender, EventArgs e)
    {




    }

    
asked by ortiga 19.07.2018 в 20:52
source

1 answer

-1

step 1.- close the program.cs (you do not have to modify anything from there)
step 2.- open the form.cs in designer mode
step 3.- in the toolbar (or toolbox) look for the "panel" control and arrange it in your form (this panel will contain the browser)
step 4 .- drag the "webbrowser" control of the toolbar and place it inside the panel

with that you already have a browser in your form, now the problem is the navigation and for that you will need to add a textbox and a navigation button

5.- drag the "textbox" control to your shape
6.- Drag the "button" control to your shape
7.- double click on the button to open the code editor and right in the middle add this line of code

  webBrowser1.Navigate(textBox1.Text);

the code will look something like this:

    private void button1_Click(object sender, EventArgs e)
    {
        webBrowser1.Navigate(textBox1.Text);
    }

finally execute your code
write the address in the text box and then press the button

- Additional--

Probably afterwards you will need the panel to expand when you make your cresca shape in size, for that you will have to modify the properties of anchor * or anchors.

These "anchors" mean that when the shape changes size, the distance to each direction is the same. If the anchors are not adjusted, the panel will never change size.

    
answered by 19.07.2018 / 21:15
source