Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Text size in WebBrowser control

Text size in WebBrowser control

Scheduled Pinned Locked Moved C#
questioncsharphelptutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Branislav Vidovic
    wrote on last edited by
    #1

    Hy guys! I have a question about text size in WebBrowser control in MS Visual C# 2005 Express Edition. You know when you view web pages in a browser you can alter the overal text size from the contex menu. For example when I open MSDN help in C#, from the context menu i can choose the text size. I actually found out that this operation afects also my webbrowser control. So if i choose "Larger" text size when i am viewing MSDN, my webbrowser control will also change it's text size. My question is: How can I control the text size in my webbrowser control? Is there a property or some way to do it? Thank you for your time. Cheers!

    A L 2 Replies Last reply
    0
    • B Branislav Vidovic

      Hy guys! I have a question about text size in WebBrowser control in MS Visual C# 2005 Express Edition. You know when you view web pages in a browser you can alter the overal text size from the contex menu. For example when I open MSDN help in C#, from the context menu i can choose the text size. I actually found out that this operation afects also my webbrowser control. So if i choose "Larger" text size when i am viewing MSDN, my webbrowser control will also change it's text size. My question is: How can I control the text size in my webbrowser control? Is there a property or some way to do it? Thank you for your time. Cheers!

      A Offline
      A Offline
      Adam R Harris
      wrote on last edited by
      #2

      Just a thought, I know you access to the DOM so you might be able to do this if you set the style on the body of the doument.

      If at first you don't succeed ... post it on The Code Project and Pray.

      A 1 Reply Last reply
      0
      • B Branislav Vidovic

        Hy guys! I have a question about text size in WebBrowser control in MS Visual C# 2005 Express Edition. You know when you view web pages in a browser you can alter the overal text size from the contex menu. For example when I open MSDN help in C#, from the context menu i can choose the text size. I actually found out that this operation afects also my webbrowser control. So if i choose "Larger" text size when i am viewing MSDN, my webbrowser control will also change it's text size. My question is: How can I control the text size in my webbrowser control? Is there a property or some way to do it? Thank you for your time. Cheers!

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Yes, the WebBrowser Control uses the settings you defined while using Internet Explorer. It also shares a lot of code with IE. For your own web pages, you can set all style attributes within your pages themselves, using either HTML, XHTML or better yet CSS. For exisiting pages, I don't know if and how you can programmatically alter the IE settings (and I would not like an app that modifies how IE works without me asking it to do so). Well, actually I don't use IE that much, there are even better browsers around :laugh:

        Luc Pattyn [Forum Guidelines] [My Articles]


        The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


        1 Reply Last reply
        0
        • A Adam R Harris

          Just a thought, I know you access to the DOM so you might be able to do this if you set the style on the body of the doument.

          If at first you don't succeed ... post it on The Code Project and Pray.

          A Offline
          A Offline
          Adam R Harris
          wrote on last edited by
          #4

          I did a little looking for you and you can call WebBrowser.Document.InvokeScript to execute some script on the document. So you could do something like this

          webBrowser1.Document.InvokeScript("body.style.style.fontSize = '10pt';");

          I'm not sure if you can directly execute javascript like that you might have to use a function. You could always add your function to a page by appending the script to WebBrowser.Document.InnerHTML InvokeScript(string) - MSDN[^] OR if you want to create a function in your page to do the sizing and pass it parameters InvokeScript(string, object)[^]

          If at first you don't succeed ... post it on The Code Project and Pray.

          B 1 Reply Last reply
          0
          • A Adam R Harris

            I did a little looking for you and you can call WebBrowser.Document.InvokeScript to execute some script on the document. So you could do something like this

            webBrowser1.Document.InvokeScript("body.style.style.fontSize = '10pt';");

            I'm not sure if you can directly execute javascript like that you might have to use a function. You could always add your function to a page by appending the script to WebBrowser.Document.InnerHTML InvokeScript(string) - MSDN[^] OR if you want to create a function in your page to do the sizing and pass it parameters InvokeScript(string, object)[^]

            If at first you don't succeed ... post it on The Code Project and Pray.

            B Offline
            B Offline
            Branislav Vidovic
            wrote on last edited by
            #5

            Thank you, this was helpfull! Cheers!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups