I have a C# winForm app that use webbrowser to load websites. All thing are good but with some websites I have extra space in left or right of webbrowser. I tested the link of site on all browsers like IE and Chrome in my windows but no one has this problem and just my app have this problem. help me to find the solution and remove space to fit my website to web browser. thnx
Asked
Active
Viewed 213 times
1 Answers
1
The WebBrowser
control in WinForms
use a legacy version of IE by default. (IE7)
That is most likely the cause of your issue, to solve it you would have to force the WebBrowser
emulation to a higher version, IE11 for example, in the windows registry.
This is a piece of code I use to do so by detecting currently installed IE version and updating it in the registry:
int BrowserVer, RegVal;
// get the installed IE version
using (WebBrowser Wb = new WebBrowser())
BrowserVer = Wb.Version.Major;
// set the appropriate IE version
if (BrowserVer >= 11)
RegVal = 11001;
else if (BrowserVer == 10)
RegVal = 10001;
else if (BrowserVer == 9)
RegVal = 9999;
else if (BrowserVer == 8)
RegVal = 8888;
else
RegVal = 7000;
// set the actual key
RegistryKey Key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true);
Key.SetValue(System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".exe", RegVal, RegistryValueKind.DWord);
Key.Close();
Simply paste the code at the beggining of your application. Furthermore, refer to this answer for extra details.
Disclaimer: The code is not originally mine, could not find a reference to it.

Community
- 1
- 1

Reousa Asteron
- 519
- 1
- 3
- 18