Hi,现在有一个 TabControl 在主界面显示,在 TabControl 里面有 3 个 TabPage ,这个 TabControl 是隐藏的,同时,在主界面有一个 Button A ,在 Button A 点击的时候,我想弹出一个窗口显示其中一个 TabPage,请问这个是否可以实现?现在想实现动态弹出一个窗口里面显示其中一个 TabPage 的内容,不想手工又去创建一个 Form,简化流程。
同时,希望弹出窗口可以按要求调整下大小。请指点一下,谢谢。

解决方案 »

  1.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void btnShowDlg_Click(object sender, EventArgs e)
            {
                Form2 f2 = new Form2();
                TabControl tc = new TabControl();
                tc.Size = this.tabControl1.Size;
                tc.TabPages.Add(this.tabPage1);
                f2.ItsControls.Add(tc);
                f2.ShowDialog();
                this.tabControl1.TabPages.Add(tc.TabPages[0]);
            }
        }
    }
    Form2
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;namespace WindowsFormsApplication1
    {
        public partial class Form2 : Form
        {
            public System.Windows.Forms.Control.ControlCollection ItsControls
            {
                get { return Controls;  }
            }        public Form2()
            {
                InitializeComponent();
            }
        }
    }
      

  2.   


    谢谢,我引用了一个第三方的 User Control ,它是一个播放器,它只提供了一个 dll 给引用,在它的文档中介绍是一个 Windows Media Player Wrapper Class, 我现在尝试去 new ThirdPartyWrapperClass() 的时候,出现以下错误:
    System.BadImageFormatException was unhandled by user code
      Message=Could not load file or assembly 'Interop.WMPLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7fb959440a58fc74' or one of its dependencies. An attempt was made to load a program with an incorrect format.
      Source=CyberTech.RecorderApi.Forms.Controls
      FileName=Interop.WMPLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7fb959440a58fc74
      FusionLog==== Pre-bind state information ===
    LOG: User = WIN-VE8T1FK2FAI\Administrator
    LOG: DisplayName = Interop.WMPLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7fb959440a58fc74
     (Fully-specified)
    LOG: Appbase = file:///D:/TestApp/bin/Release/
    LOG: Initial PrivatePath = NULL
    Calling assembly : ThirdParty.AppName.Forms.Controls, Version=3.2.0.50, Culture=neutral, PublicKeyToken=7fb959440a58fc74.
    ===
    请帮忙看下是什么问题?谢谢。
      

  3.   

    直接引用COM组件
    Windows Media Player (WMPLib.dll)
      

  4.   


    因为现在有些加密内容必须使用该第三方播放器提供的 dll ,所以,我没办法只使用 Windows Media Player 来播放文件,要使用它的播放器才可以,请看下上面是什么回事?
      

  5.   


    我已经把 WMPLib.dll 引用进来了,也是一样的错误,请帮忙。