Because the default browser for the WebBrowser control of VS is IE7, a lot of Web page compatibility is not very good, so you have to modify the default browser.
Before setting: After setting:
When loading the WebBrowser interface, perform the following methods to set the browser.
1 /// <summary>2 ///to define an enumeration of IE versions3 /// </summary>4 Private enumieversion5 {6Forced Ie10,//10001 (0x2711) Internet Explorer 10. Web page in the IE 10 standard mode display, page! DOCTYPE Invalid7Standard IE10,//10000 (0x02710) Internet Explorer 10. In IE 10 Standard mode, follow the page! DOCTYPE instructions to display the Web page. Internet Explorer 10 default value. 8Forced IE9,//9999 (0x270f) Windows Internet Explorer 9. Force IE9 display, ignore! DOCTYPE Directive9Standard IE9,//9000 (0x2328) Internet Explorer 9. Internet Explorer 9 Default value, in IE9 Standard mode, follow the page! DOCTYPE instructions to display the Web page. TenForced IE8,//8888 (0X22B8) Internet Explorer 8, Force IE8 Standard mode display, ignore! DOCTYPE Directive OneStandard IE8,//8000 (0X1F40) Internet Explorer 8 default settings, in IE8 Standard mode, follow the page! DOCTYPE Command Display Web page AStandard IE7//7000 (0x1b58) uses the default value used by the WebBrowser control application in IE7 Standard mode on the Web page! DOCTYPE instructions to display Web pages - } - the /// <summary> - ///set the default version of WebBrowser - /// </summary> - /// <param name= "ver" >IE version</param> + Private voidSetie (ieversion ver) - { + stringProductName = AppDomain.CurrentDomain.SetupInformation.ApplicationName;//Get program Name A at Objectversion; - Switch(ver) - { - Caseieversion. Standard IE7: -Version =0x1b58; - Break; in Caseieversion. Standard IE8: -Version =0x1f40; to Break; + Caseieversion. Mandatory IE8: -Version =0x22b8; the Break; * Caseieversion. Standard IE9: $Version =0x2328;Panax Notoginseng Break; - Caseieversion. Mandatory IE9: theVersion =0x270f; + Break; A Caseieversion. Standard IE10: theVersion =0x02710; + Break; - Caseieversion. Mandatory IE10: $Version =0x2711; $ Break; - default : -Version =0x1f40; the Break; - }Wuyi theRegistryKey key =Registry.currentuser; -RegistryKey software = Wu key. CreateSubKey ( - @"software\microsoft\internet explorer\main\featurecontrol\feature_browser_emulation\"+productName); About if(Software! =NULL) $ { - software. Close (); - software. Dispose (); - } ARegistryKey Wwui = + key. OpenSubKey ( the @"software\microsoft\internet Explorer\main\featurecontrol\feature_browser_emulation",true); - //the item must already exist $ if(Wwui! =NULL) Wwui. SetValue (ProductName, version, Registryvaluekind.dword); the}
Display Code
Call:
Setie (ieversion. Standard IE8);
Winform Technology Exchange Group: Jiang Zuo Union [winform]376034405 the leader provides a variety of self-painted control use, group sharing can be downloaded! Welcome to the comrades who are still doing Winform!
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
C # settings WebBrowser default browser