• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 526
  • Last Modified:

add rdp control to tab control as additional tabs are created

I working on an RDP client. My plan is to integrate this with other tools I have created for work.  I have a menustrip, tabcontrol and a rdp control on the first tab.  For now, I have setup the app to add a new tab when a user clicks connect.  This works great.  What I cant figure out is how to add another rdp control to the new tab.  Any help would be great.

Imports MSTSCLib

Public Class frmMain
    Private Sub ConnectToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConnectToolStripMenuItem.Click
        If AddTab() Then
            rdpConnect()
        End If
    End Sub

    Private Sub DisconnectToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisconnectToolStripMenuItem.Click

        TabControl1.Visible = True
        


    End Sub

    Private Sub frmMain_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        TabControl1.Width = Me.Width - 35
        TabControl1.Height = Me.Height - 110
    End Sub

    Private Function AddTab()
        Try
            Dim myTabPage As New TabPage()
            myTabPage.Text = "NewTab" & (TabControl1.TabPages.Count + 1)
            TabControl1.TabPages.Add(myTabPage)
            Return True

        Catch ex As Exception
            Return False
        End Try

    End Function

    Private Sub rdpConnect()
        If rdp.Connected.ToString() = "0" Then
            Try
                rdp.Server = "***.***.***"
                rdp.UserName = "User"
                Dim secured As IMsTscNonScriptable = DirectCast(rdp.GetOcx(), IMsTscNonScriptable)
                secured.ClearTextPassword = "Pass"
                rdp.Connect()
            Catch ex As Exception
                MessageBox.Show(ex.Message, Me.Name, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        End If
    End Sub
End Class

Open in new window

0
NCSA SCADA
Asked:
NCSA SCADA
  • 2
1 Solution
 
NCSA SCADAAuthor Commented:
Any help experts?
0
 
CodeCruiserCommented:
RDP is just a control so you can instantiate it in code and add it to tab control

Example:

Dim rdp as new RDPClient
rdp.width = 600
rdp.height = 400
rdp.left = 10
rdp.top = 20

TabControl1.Tabs(2).Controls.Add(rdp)
0
 
NCSA SCADAAuthor Commented:
I was making this way to hard.... thanks for the help
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now