标签页索引问题 [英] Tabpage index problem

查看:110
本文介绍了标签页索引问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是C#应用程序的初学者,并且具有简单的Web浏览器应用程序,我的问题是:
如果我打开浏览器并输入网址,就可以了
但是如果我打开新的(第二个标签页)&在网址地址文本框中添加网址网站,应用程序在第一个标签页中打开我的请求网址

解决问题的方法是什么

是我的问题来自webbrowser对象,还有哪种更好的方法来创建
webbrowser对象和tabcontrol可以创建许多选项卡页,而无需将webbrowser对象移动到另一个
我已将视频链接添加到我的简单Web浏览器中,以便您可以了解问题所在:

从OP更新:
请观看视频以了解问题:
http://www.mediafire.com/?n0rvqvo4s14n78s [

I''m beginner in C# apllication and have simple web browser application my problem was:
If I open the browser and enter url address it will be fine
but if i open new (second tab page) & add url web site in url address textbox the application open my request url in the first tab page

what is the solution to solve the problem

Is my problem from webbrowser object and which better method to create
webbrowser object and tabcontrol to create many tabpage without move webbrowser object to another
I have added video link to my simple webbrowser such that you can understand the problem:

Update from OP:
please see the video to understand problem:
http://www.mediafire.com/?n0rvqvo4s14n78s[^]

推荐答案

看看这些文章:

使用C#的Web浏览器 [多标签Web浏览器 [
Have a look at these articles:

Web Browser in C#[^]

Multi Tab WebBrowser[^]

Good luck!


这是在tabcontrol中获取当前actve标签页的简单方法

here is a simple way to get the currently actve tabpage within the tabcontrol

TabPage ActiveTab()
{
    if (tabControl1.SelectedTab != null)
    {
        return tabControl1.SelectedTab;
    }
    return null;
}



这是获取当前活动的WebBrowser的简单方法.



here is a simple way to get the currently active WebBrowser

WebBrowser ActiveBrowser()
     {
         if (tabControl1.SelectedTab != null)
         {
             foreach (Control control in tabControl1.SelectedTab.Controls)
             {
                 if ((control) is WebBrowser)
                 {
                     return (WebBrowser)control;
                 }
             }
         }
         return null;
     }



现在要在活动选项卡中找到WebBrowser,只需使用此



Now to find the WebBrowser within the active tab just use this

WebBrowser Browser = ActiveBrowser();
        if (Browser != null)
        {
            // do what you need with the active browser here
        }


这篇关于标签页索引问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆