Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

190
Vistas
C# How to make all pages fit into Panel without adding horizontal scroll bar in cefSharp browser

In WinForms my Panel size is 560x371. Some pages fit into this size without adding horizontal scroll bar but some pages do not fit and horizontal scroll bar adds. How to make all pages fit (without exception) and without adding horizontal scroll bar?

For example: google.com fit into Panel without adding horizontal scroll bar, but yahoo.com does not fit and adds horizontal scroll bar

Here is my code

        public ChromiumWebBrowser chrome;
        public CefSettings settings;
        string main_site = "https://yahoo.com";

        public Form1()
        {
            InitializeComponent();
            InitBrowser();
        }

public void InitBrowser()
        {
            settings = new CefSettings()
            {
                LogFile = "Debug.log", //You can customise this path
                LogSeverity = LogSeverity.Default // You can change the log level
            };
            string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            settings.CachePath = path;
            Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);
            chrome = new ChromiumWebBrowser(main_site);
            this.panel1.Controls.Add(chrome);
            chrome.MenuHandler = new DevToolsMenuHandler();
            chrome.AddressChanged += Chrome_AddressChanged;
            chrome.LifeSpanHandler = new MyCustomLifeSpanHandler();
       }

My new addintion (26.04.2022)

I also added code below

        private async void OnBrowserFrameLoadEnd(object sender, FrameLoadEndEventArgs args)
        {
            var client = chrome.GetDevToolsClient();
            await client.Emulation.SetDeviceMetricsOverrideAsync(500, 1000, 0, false);
        }

chrome.FrameLoadEnd += OnBrowserFrameLoadEnd;

You can see in the screenshot below, the code above trims the page. But i need to fit all content into Panel without loss of content

launch app result

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda