1

I am working on a WinForm (weather app) that use the IE Webbrowser control which displays a weather Map image from Weather Underground. My problem is that it shows a white margin (or padding) of about 5 px or so, and I can not seem to figure out how to get rid of this white space.(Take a look at image)

I have tried just the Chrome Browser and there is no white space (margin) around the image, however if I try my IE Browser I get the white space(margin). Is there a setting in IE that sets a Top / Left Margin?

I don't particularly won't to use another webcontrol like Chromium or some other Third party web control, but I will if I have to or either I'll use something a picturebox if I have to. I was just trying to use the webcontrol.

Image of IE browser control Image of IE browser control

Wagner DosAnjos
  • 6,304
  • 1
  • 15
  • 29

1 Answers1

1

All browsers have default margins on body but Chrome seems smart enough to not use them when viewing an image instead of HTML. Perhaps inject body { margin: 0; } using How to inject CSS in WebBrowser control?

If you load an image in IE and then use F12, it produces:

<html>
  <head></head>
  <body>
    <img src="file:///C:/Users/Public/Pictures/Sample%20Pictures/Chrysanthemum.jpg">
  </body>
</html>

And if you manually add margin: 0; to the body the border goes away.

Community
  • 1
  • 1
Paul Abbott
  • 7,065
  • 3
  • 27
  • 45
  • Paul thanks for the heads up on how to inject CSS. I figured there was a way to control the Web Browser StyleSheet from within C#, however I changed the webBrowser control to a picture box to get rid of the confusion on my part. Again thanks for the help, I'm sure I'll need more in the future. – John Edenfield Jan 06 '17 at 20:44