C#将RDP客户端控件添加到选项卡控件

C#将RDP客户端控件添加到选项卡控件,c#,tabs,controls,add,rdp,C#,Tabs,Controls,Add,Rdp,我正在制作一个程序,通过Windows RDP管理多个远程桌面会话。我找到了一个教程,该教程演示了如何通过将AxMsRdpClient2a控件拖动到表单设计器中的控件来使用该控件。但我想在选项卡控件中动态创建它们(即用户单击按钮并创建包含远程桌面客户端的新选项卡)。由于某些原因,在运行AxMsRdpClient2a控件时,该控件未显示在选项卡页面中。这是我正在使用的代码,任何建议都将不胜感激 // Create a new tab for the remote deskt

我正在制作一个程序,通过Windows RDP管理多个远程桌面会话。我找到了一个教程,该教程演示了如何通过将AxMsRdpClient2a控件拖动到表单设计器中的控件来使用该控件。但我想在选项卡控件中动态创建它们(即用户单击按钮并创建包含远程桌面客户端的新选项卡)。由于某些原因,在运行AxMsRdpClient2a控件时,该控件未显示在选项卡页面中。这是我正在使用的代码,任何建议都将不胜感激

            // Create a new tab for the remote desktop
        tabs[currentTab] = new TabPage();
        clients[currentTab] = new AxMsRdpClient2a();
        clients[currentTab].CreateControl();
        clients[currentTab].BringToFront();
        clients[currentTab].Parent = tabs[currentTab];
        clients[currentTab].ColorDepth = 16;
        //clients[currentTab].Location = new Point(0, 0);
        //clients[currentTab].Size = new System.Drawing.Size(50, 50);

        tabs[currentTab].Controls.Add(clients[currentTab]);
        tabs[currentTab].Name = RemoteIP;
        tabs[currentTab].Padding = new System.Windows.Forms.Padding(3);
        tabs[currentTab].Size = remoteDesktopTabControl.Size;
        clients[currentTab].DesktopWidth = tabs[currentTab].Width;
        clients[currentTab].DesktopHeight = tabs[currentTab].Height;
        clients[currentTab].AdvancedSettings3.DisplayConnectionBar = true;
        tabs[currentTab].Text = RemoteIP;
        tabs[currentTab].UseVisualStyleBackColor = true;
        remoteDesktopTabControl.TabPages.Add(tabs[currentTab]);
        tabs[currentTab].Controls.Add(new RichTextBox());

        remoteDesktopTabControl.SelectedTab = remoteDesktopTabControl.TabPages[remoteDesktopTabControl.TabPages.Count - 1];

        clients[currentTab].Server = RemoteIP;
        clients[currentTab].UserName = Username;
        IMsTscNonScriptable secured = (IMsTscNonScriptable)clients[currentTab].GetOcx();
        secured.ClearTextPassword = Password;
        clients[currentTab].ColorDepth = 16;
        clients[currentTab].Connect();

        currentTab++;

下面是我如何动态创建控件的

AxMsRdpClient7NotSafeForScripting newrdp = new AxMsRdpClient7NotSafeForScripting();
                newrdp.Name = "RDPControl";
                tab.Controls.Add(newrdp);
                tab.Size = new System.Drawing.Size(814, 508);

                tabControl.TabPages.Add(tab);
                tabControl.SelectedTab = tab;
                ConnectNewTab(newrdp, serverTextBox.Text, usernameTextBox.Text, passwordTextBox.Text);
我包含该名称的原因是,我使用另一种方法在特定选项卡上按该名称查找控件,以便可以正常断开连接