tags:

views:

390

answers:

2

When I add a WebBrowser control on my TabPage, it doesn't have a border. I can't find a BorderStyle attribute. How do get the control to have a border? (3D, sunken, whatever)

Screenshot

Only by the scrollbar on the right you see there's actually a control there...

+2  A: 

You can wrap the WebBrowser control in a Panel and set the Panel.BorderStyle property.

Panel panel1 = new Panel();
panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
panel1.Controls.Add(webbrowser1);
dtb
That's a way ofcourse :)But why do all controls have a border-style except the webbrowser ?
Pygmy
Web browser is special :-)
Kugel
+4  A: 

Gumpy comments, not accurate. Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of your toolbar onto your form.

using System;
using System.Windows.Forms;

class MyWebBrowser : WebBrowser {
  protected override CreateParams CreateParams {
    get {
      var parms = base.CreateParams;
      parms.Style |= 0x800000;  // Turn on WS_BORDER
      return parms;
    }
  }
}

The other border styles work too, check out WinUser.h in the SDK.

Hans Passant
Good answer. If one is new to windows like me, my WinUser.h was here (probably visual studio put it there): C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\
DGGenuine