Changing Winform webbrowser control IE version in C#.NET


Webbrowser control internally uses internet explorer installed in user's machine for rendering the webpages, but by default it runs in IE7 compatibility mode, assuming user's machine has IE version >=7.

  

You can change the Winform Webbrowser control above behavior   by adding a key in registry. Make sure , you add the registry key , before Webbrowser control is loaded.



You don't need to add registry key every time you run the application. It is one time process.

If you add it once , it remains forever, and when ever your application has started, it reads the registry value and accordingly the webbrowser control renders.



Please find the below code snippet to add/check for your application registry key







         private  static  void  SetIE8KeyforWebBrowserControl()
         {
             RegistryKey  Regkey = null ;
             try 
             {
 
                 //For 64 bit Machine 
                 if  (Environment .Is64BitOperatingSystem)
                     Regkey = Microsoft.Win32.Registry .LocalMachine.OpenSubKey(@"SOFTWARE\\
Wow6432Node\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION" , true );
                 else  //For 32 bit Machine 
                     Regkey = Microsoft.Win32.Registry .LocalMachine.OpenSubKey(@"SOFTWARE\\
Microsoft \\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION" , true );
 
 
                 //If the path is not correct or 
                 //If user't have priviledges to access registry 
                 if  (Regkey == null )
                 {
                     Console .WriteLine("Application Settings Failed - Address Not found" );
                     return ;
                 }
 
 
                 string  FindAppkey = Convert .ToString(Regkey.GetValue("ApplicatonName.exe" ));
 
                 //Check if key is already present 
                 if  (FindAppkey == "8000" )
                 {
                     Console .WriteLine("Required Application Settings Present" );
                     Regkey.Close();
                     return ;
                 }
 
                 //If key is not present add the key , Kev value 8000-Decimal 
                 if  (string .IsNullOrEmpty(FindAppkey))
                     Regkey.SetValue("ApplicatonName.exe" , unchecked ((int )0x1F40),
                         RegistryValueKind .DWord);
 
 
                 //check for the key after adding 
                 FindAppkey = Convert .ToString(Regkey.GetValue("ApplicaitonName" ));
 
                 if  (FindAppkey == "8000" )
                     Console .WriteLine("Application Settings Applied Successfully" );
                 else 
                     Console .WriteLine("Application Settings Failed" );
 
 
             }
             catch  (Exception  ex)
             {
                 Console .WriteLine("Application Settings Failed" );
                 Console .WriteLine(ex.Message);
             }
             finally 
             {
                 //Close the Registry 
                 if  (Regkey != null )
                     Regkey.Close();
             }
         }
 

Zooming in Winforms Webbrowser Control in .NET
Filtering Datatable with Select Conditions and Sorting in C#.NET
Hiding a property from displaying in Datagridview in C#.NET
Logic to detect if Application is started from Citrix/Terminal Server/PC in C#
Winforms Application.DoEvents Method
Modify XML file with tagname in c#.net
Read Machine IP Address in C#
Check if IIS is running using C#
Implementing IEnumerable in C#
Built in Delegates in .NET Framework
Set the dropdown width of any combobox based on the data
Difference between Const and ReadOnly
Example for Property Change Notification in C#.NET
Example Program using Delegates and Events in C#
AutoComplete in .NET Winforms TextBox
How to read data from XML String and insert in to table in SQL Server
WebBrowser.navigate Data Submission by Get or Post Methods
Datagridview Paging
Copy Datagridview cell value using ContextMenu
Inserting data in Datatable in C#
Cookie in .NET
Using Control's Child Index and Dock property for achieving desired layout in a form.
Accessing section group inside configuration of web.config
Create File in .NET C#
Change button shape in .net
Dispose vs Finalize in .net




Changing Winform webbrowser control IE version in C#