Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

195
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda