简体   繁体   中英

web browser control in winform with google chrome c#

hello all i am creating a winform app in which i am showing a map to all the user but the problem is web browser control is taking ie7 as a default browser and map is not supporting in that particular browser,

error:

You are using a browser that is not supported by the Google Maps JavaScript API. Consider changing your browser.Learn moreDismiss

i want to open the map from web browser control but not with ie, i want to show with google chrome to get rid of that error,

and i have many administrative rights in my system i can't use registry

is there any ways to do that?

The Browser component uses the Internet Explorer as engine, so if you want another browser you have to find a component for that.

CefSharp uses chromium as engine.

VS default browser control use IE. You should use cefsharp for chrome browser. First include the library and initialize like this...

public ChromiumWebBrowser browser;
private void InitBrowser()
    {
        try
        {
            if (!Cef.IsInitialized)
            {
                CefSettings settings = new CefSettings();
                settings.BrowserSubprocessPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "CefSharp.BrowserSubprocess.exe");

                Cef.Initialize(settings);
            }
            string url = "www.google.com";

            browser = new ChromiumWebBrowser(url);             
            this.Controls.Add(browser);
            browser.Dock = DockStyle.Fill;

            browser.IsBrowserInitializedChanged += browser_IsBrowserInitializedChanged;
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message.ToString());
        }
    }

    private void browser_IsBrowserInitializedChanged(object sender, IsBrowserInitializedChangedEventArgs e)
    {
        if (((ChromiumWebBrowser)sender).IsBrowserInitialized)
        {
            //if needed then use dev tool
            browser.ShowDevTools();
        }
    }

For more info please see below link... https://github.com/cefsharp/CefSharp https://github.com/cefsharp/CefSharp/wiki/Quick-Start

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM