WebBrowser - find the height of the displayed text

I have a web browser control that should have a certain height. If the user has short text, I want the web browser to be short. If the user is typing a lot of text, then I need the web browser to be much higher.

How can I find the height of the displayed text from WebBrowser?

I saw this Get page height using a C # web browser control , but thought there was a better way.


Update

I set the browser text:

webBrowser1.DocumentText = value;

After I set this value, I can check the webBrowser1.Document.Body file and its null value. I can also get all the children of the document, and no one returns.

Am I setting the correct property?

+3
3

-, webBrowser.DocumentText, , "" .

webBrowser1.DocumentText = "Some Text";

labelHtml.Text = webBrowser1.DocumentText

, -, , . , "Some Text" - , , "labelHtml" , . ( "Some Text", .)

WebBrowser control webBrowser1_documentCompleted DocumentText, .

    private void setText(string htmlText)
    {
            webBrowser1.DocumentText = htmlText;
    }


    private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
        label1.Text = webBrowser1.DocumentText;
    }

label1 , -...

+3

:

BODY OffsetRectangle.Bottom . .

- , , .


webBrowser1.DocumentText -? , ?

+2

-...

" - #" System.Windows.Forms.HtmlElementcollection, Compact Framework. , .NET CF. .

0

Source: https://habr.com/ru/post/1720126/


All Articles