开发者

Get WebBrowsers parent control

Ive been trying to get the parent of this WebBrowser control. Somehow i can't seem to find the right way of getting the parent. i thought it would work like this :

private void webtabItem1_Navigated(object sender, NavigationEventArgs e)
{
    WebBrowser Webr = (WebBrowser) sender;
    CloseableTabItem Tab = (CloseableTabItem) Webr.Parent);
    Tab.Header = e.Uri.Host;
}

It gives the error "Only assignment, call, i开发者_如何学编程ncrement, decrement, and new object expressions can be used as a statement" on .Parent. MSDN tells you can only access it as a object i tried but it doesn't seem to work.

I could get the child of the tab by means of .Content

WebBrowser Webr = (WebBrowser)Tab.Content;

It's probably not that hard just some stupid mistake of me.


The error is due to an extra parenthesis after Parent, try:

CloseableTabItem Tab = (CloseableTabItem)Webr.Parent;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜