• Log in or sign up for an account here: https://www.sythe.org/login

Visual Basic 2010 - Need help

VPf2

Member
Joined
May 1, 2007
Sythe Gold
0
Messages
48
Visual Basic 2010 - Need help
Hey,

I need a simple tip. What is the correct code to create a new tab with a DockStyle.Fill RichTextBox (in a DotNetBar.SuperTabControl) when you click a button. I'm at a loss >_<

Here's my app:
72246772.jpg


And the code. You'll probably see what I'm trying to do:
14520657.jpg
 
Visual Basic 2010 - Need help
This might help

Code:
Private Sub AddTab(Optional ByVal file As String = Nothing)
    Dim NewTab As New TabPage 'Create a new tab
    Dim NewRTB As New RichTextBox 'Create a new richtextbox

    Dim TabText As String = "Untitled" 'Text for the tab. Default is "Untitled"
    Dim RTBText As String = Nothing 'Text for the richtextbox. Default is Nothing

    If Not IsNothing(file) Then 'If a file was set
        If My.Computer.FileSystem.FileExists(file) Then 'If the file exists
            NewRTB.Tag = file 'Set the file as the new richtextbox's tag for later use
            TabText = My.Computer.FileSystem.GetFileInfo(file).Name 'Get the filename
            Dim reader As New System.IO.StreamReader(file) 'Create a reader to read the file
            RTBText = reader.ReadToEnd 'Read all the text of the file
            reader.Close() ' Close the reader
        Else
            MsgBox("Sorry that file doesn't exist") 'Inform the user if the file doesn't exist
        End If
    End If

    NewTab.Text = TabText 'Set the tabs text
    NewTab.Tag = NewRTB 'Set the richtextbox as the Tab's tag for later use

    NewRTB.Parent = NewTab 'Make the richtextbox a child of the tag
    NewRTB.Dock = DockStyle.Fill 'Make the richtextbox fill the tabpage
    NewRTB.Text = RTBText 'Set the richtextbox's text

    TabControl1.TabPages.Add(NewTab) 'Add the tab to the tabcontrol
    TabControl1.SelectedTab = NewTab 'Focus on the new tab
    Tab = NewTab 'Set the current tab to NewTab
    RTB = NewRTB 'Set the current richtextbox to NewRTB
End Sub
 
Runescape Gamblingrunescape gambling
Back
Top