我要做一个像IE7一样的多窗口程序,例如打开菜单中的系统设置,直接第一个窗口的右边打开一个新窗口,里面是关于用户管理的面板,因为TAB控件不好用,希望大虾给个思路,或者给个例子的源码,万分感谢!
注意是用C#写的应用程序,不是WEB程序!!!

解决方案 »

  1.   

    如果嫌微软的Tab难看的话,可以自己寻找特效的Tab控件
      

  2.   

    不是嫌弃TAB控件不好用,是不知道怎么动态加载窗体?
      

  3.   

    创建一个axWebBrowser的实例,再创建一个TabPage的实例,把axWebBrowser的实例加入TabPage中添加到TabControl显示。
      

  4.   

    十分感谢LS的兄弟,axWebBrowser控件在VS2005找不到,WebBrowser倒是有,不过这个控件也没 用过...
      

  5.   

    在vs2005工具箱上点击右键,添加对Microsoft Web Browser控件(COM组件)的引用,就可以看到axWebBrowser了。
      

  6.   

    如果喜欢这样的界面,看看DockPanel Suite,你要的效果就是DockingMDI的效果了。
      

  7.   

    http://blog.csdn.net/wzuomin/archive/2008/03/03/2141941.aspx
      

  8.   

    网上有类似的实例吧,down一个,我以前查到过,我看看,要是能找到就贴出来!
      

  9.   

    这个我很久以前用tabcontrol写过的,代码还在.CustomTabpage.cs 类class CustomTabpage:System.Windows.Forms.TabPage
        {
            private System.Windows.Forms.WebBrowser webBrowser;
            private string _Navigate = "about:blank";
            
            public string Navigate
            {
                get { return _Navigate; }
                set
                {
                    _Navigate = value;
                    this.Text = value;
                    if (webBrowser != null)
                    {
                        webBrowser.Navigate(_Navigate);
                    }
                }
            }        protected override void OnCreateControl()
            {
                webBrowser = new System.Windows.Forms.WebBrowser();
                webBrowser.Dock = System.Windows.Forms.DockStyle.Fill;
                webBrowser.ScriptErrorsSuppressed = false;
                webBrowser.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(webBrowser_DocumentCompleted);
                webBrowser.NewWindow += new System.ComponentModel.CancelEventHandler(webBrowser_NewWindow);
                webBrowser.Navigating += new System.Windows.Forms.WebBrowserNavigatingEventHandler(webBrowser_Navigating);
                webBrowser.
                webBrowser.Visible = true;
                this.Controls.Add(webBrowser);
                base.OnCreateControl();
            }        void webBrowser_Navigating(object sender, System.Windows.Forms.WebBrowserNavigatingEventArgs e)
            {
                //当点击网页跳转时,使地址栏重新获得跳转后的地址
                _Navigate = this.webBrowser.Document.Url.ToString();
                ((webBrowserForm)(this.Parent.Parent)).Url = _Navigate;
                //throw new Exception("The method or operation is not implemented.");
            }        void webBrowser_NewWindow(object sender, System.ComponentModel.CancelEventArgs e)
            {
                //阻止用IE新开窗口
                e.Cancel = true;
                webBrowser.AllowNavigation = false;
                //为父容器添加新的选项卡
                CustomTabpage tabpage = new CustomTabpage();
                ((System.Windows.Forms.TabControl)(this.Parent)).TabPages.Add(tabpage);
                ((System.Windows.Forms.TabControl)(this.Parent)).SelectedTab = tabpage;            //获得当前截获的新开窗口的URL
                string url = this.webBrowser.Document.ActiveElement.GetAttribute("href");
                //如果非链接而是表单提交及脚本的话,此时会取不到值,所以需要下面的判断
                if (!string.IsNullOrEmpty(url))
                {
                    tabpage.Navigate = url;
                    ((webBrowserForm)(this.Parent.Parent)).Url = url;
                }
                webBrowser.AllowNavigation = true;
                //throw new Exception("The method or operation is not implemented.");
            }        void webBrowser_DocumentCompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
            {
                //页面加载完成后给窗口及选项卡加标题
                this.Text = webBrowser.Document.Title;
                this.Parent.Parent.Text = webBrowser.Document.Title;
                //throw new Exception("The method or operation is not implemented.");
            }    }
                //用的时候,需要新建页面就:
                  CustomTabpage tabpage = new CustomTabpage();
                this.tabControl.TabPages.Add(tabpage);
                tabpage.Navigate = this.urlBox.Text.Trim();
                this.tabControl.SelectedTab = tabpage;
      

  10.   

    private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
            {
                //切换选项卡时,给地址栏赋予当前选项卡页面地址及标题
                if (this.tabControl.SelectedTab != null)
                {
                    this.urlBox.Text = ((CustomTabpage)(this.tabControl.SelectedTab)).Navigate;
                    this.Text = ((CustomTabpage)(this.tabControl.SelectedTab)).Text;
                }
                else
                {
                    this.urlBox.Text = "about:blank";
                    this.Text = "空白页";
                }
            }        private void tabControl_MouseDown(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Right)
                {
                    //使右键激活选项卡
                    for (int i = 0; i < tabControl.TabPages.Count; i++)
                    {
                        CustomTabpage tp = (CustomTabpage)(tabControl.TabPages[i]);
                        if (tabControl.GetTabRect(i).Contains(new Point(e.X, e.Y)))
                        {
                            tabControl.SelectedTab = tp;
                        }
                    }                //显示菜单
                    this.contextMenuStrip1.Show(this.tabControl,e.Location);
                }
            }
            private void NewMenuItem_Click(object sender, EventArgs e)
            {
                //添加当前选中的选项卡副本
                CustomTabpage tp = new CustomTabpage();
                tp.Text = ((CustomTabpage)(this.tabControl.SelectedTab)).Text;
                this.tabControl.TabPages.Add(tp);
                tp.Navigate = ((CustomTabpage)(this.tabControl.SelectedTab)).Navigate;
                this.tabControl.SelectedTab = tp;
                this.urlBox.Text = tp.Navigate;
                this.Text = tp.Text;
            }        private void NewBlankMenuItem_Click(object sender, EventArgs e)
            {
                //新建空白页选项卡
                CustomTabpage tabpage = new CustomTabpage();
                tabpage.Navigate = "about:blank";
                tabpage.Text = "空白页";
                this.tabControl.TabPages.Add(tabpage);
                this.Text = "空白页";
                this.urlBox.Text = "about:blank";
                this.tabControl.SelectedTab = tabpage;
            }