C# Changing WebBrowser.ScrollbarsEnabled property shows Invalid URI exception
When I simply execute the following line of code
wMessages.ScrollBarsEnabled = true;
I can see the System.UriFormatException
in IntelliTrace data, saying "Invalid URI: The hostname could not be parsed."
. I can't catch this exception, it's shown only in IntelliTrace. Removing the code makes my webbrowser work perfectly, but I need these scrollbars.
I can't understand what is the link between scrollbars and URI? Maybe it has something to do with the Document
property of the browser? The URL of the document is "about:blank"
.
Any suggestions?
UPD:
Here is the full code:
string h = "";
if (currentpage != null)
h = template + "<body><div class=\"messages\">" + currentpage.Messages() + "</div><div></div></body开发者_C百科></html>";
else
h = template + "<body><div class=\"messages\">" + "</div><div></div></body></html>";
wMessages.ScrollBarsEnabled = false;
Misc.OpenNew(wMessages, h);
try
{
if (wMessages == null) return;
if (wMessages.Document == null) return;
}
catch (System.Exception)
{
return;
}
HtmlElement body = wMessages.Document.Body;
wMessages.Dock = DockStyle.Top;
const double MaxHeightRatio = 0.4;
int availableHeight = pContainer.Height - wHeader.Height - pFooter.Height;
int BodyHeigth = (int)body.ScrollRectangle.Height;
if (BodyHeigth > (int)(availableHeight * MaxHeightRatio))
{
wMessages.Height = (int)(availableHeight * MaxHeightRatio);
wMessages.ScrollBarsEnabled = true; // here goes the exception
}
else
{
//wMessages.ScrollBarsEnabled = false;
wMessages.Height = BodyHeigth;
}
wMessages.Visible = true;
精彩评论