0

When I drag the control in the designer of form1 from the toolbox the control is in the front:

The ChromiumWebBrowser control is on the top of everything when dragging it from the toolbox:

chromiumwebbrowser is on the top

The problem is that I don't want the control to be on top of everything if I'm not running the application and clicking a button. I want the control to be in the form1 designer but not on the top.

so, I thought to create the control by code:

private void btnShowOnGoogleMaps_Click(object sender, EventArgs e)
        {
            ChromiumWebBrowser chromiumWebBrowser1 = new ChromiumWebBrowser();
            chromiumWebBrowser1.Size  = new Size(500,500);
            chromiumWebBrowser1.Show();
            chromiumWebBrowser1.Load("D:\\Csharp Projects\\Weather\\map.html");
        }

but with the code when I click the button the control is in the back. no matter what I tried.

I tried to add this line:

chromiumWebBrowser1.BringToFront();

but it didn't change much. this is the control after clicking the button:

you can see the control (with the map) on the left side of the form1 on the left edge and the control is behind everything else.

I marked with red ellipse the control to show where it is hiding behind.

the control is on the left side edge of form1 behind everything

jhon barns
  • 23
  • 6
  • Can you take a look at this answer and see if it helps solve your problem? "_In WinForms you can show any control (e.g. PictureBox) over any other control (e.g. WebView2) by adding the former to the Controls collection of the latter._" https://stackoverflow.com/a/75460185/5438626 – IVSoftware Mar 04 '23 at 14:17

1 Answers1

0

Is there a ZOrder function for this control? Usually you can just do control.ZOrder(0) to bring the control in front.