开发者

Get WebBrowsers parent control

开发者 https://www.devze.com 2023-03-13 21:13 出处:网络
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 :

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

精彩评论

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

关注公众号