Hi,
i have a windows form containing a webBrowser control. I set the content of the webbrowser control dynamically by webBrowser.DocumentText = sb.ToString();.
The content is a html table that can have a diffrent size (width and hight). I want now that the html content fit in exactly the webbrowser control and the webbrowser should exactly fit in the form. There should be no scrollbars visible. Can i somehow get the width and height of the html content to set the size of the webbrowser control and the form ?
Any help is appreciated
Bechir BejaouiPosted Sep 11, 2008, 8:55 PM
KlausPosted Sep 9, 2008, 5:00 AM
maybe i misunderstand you but i want to do this the other way around. I want to adjust the size of windows form (with webbrwoser control) to the size of the HTML-content.
Something like that:
webbrowser.size.width = width of the HTML-Content;
webbrowser.size.height = height of the HTML-Content;
I think i forgot to tell you that the HTML-content is generated by XSL. The XML comes from user interaction with another application. The user has the ability to customize the XSL. Therefore the HTML is dynamic.
This is how i transform the XML into html:
private string popupXML;
private string popupXSL;
xmlDocument.LoadXml(this.popupXML);
xmlTextReader = new XmlTextReader(new StringReader(xmlDocument.OuterXml));
xPathDocument = new XPathDocument(xmlTextReader, XmlSpace.Default);
xlsTransform = new XslCompiledTransform();
XmlReaderSettings settings = new XmlReaderSettings();
settings.ProhibitDtd = false;
xmlReader = XmlReader.Create(new StringReader(this.popupXSL), settings);
xlsTransform.Load(xmlReader);
StringBuilder sb = new StringBuilder();
tw = new StringWriter(sb);
xlsTransform.Transform(xPathDocument, null, tw);
Bechir BejaouiPosted Sep 8, 2008, 12:39 PM
if you have a html table for each cellule you dynamicallly fix the height as webbrowser.height/n where n = total number of rows in the table, the you do the same think with the cellules width where they must be equal to webbrowser.width/m where m = total number of columns, the table could be wiritten from witihn the C# code editor using a HtmlTextWriter object