VB: What exactly is wrong with this code (see question)? I'll tell you the error once I post the code. @nincompoop
`Private Sub NewToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles` `NewToolStripMenuItem1.Click` ` Dim Tab As New TabPage` ` Tab.Controls.Add(srtb)` ` srtb.Dock = DockStyle.Fill` ` Tab.Text = "New Document"` ` TabControl1.TabPages.Add(Tab)` ` End Sub`
The problem is that when I click the toolstripmenuitem, it adds a new tab, but acts like I put srtb.dispose() for the previous tab. So, it adds a new tab, but takes the srtb control out of the already existing tab.
not really :<
It probably conflicts with an earlier piece of code. Also why don't you try an easier method? ``` Dim myTabPage As New NewTab() myTabPage.Text = "NewTab" & (TabControl1.NewTabs.Count + 1) TabControl1.NewTabs.Add(myTabPage) ``` I typed that from my knowledge of C#. The converted it into VB.NET... It may bring a few errors, but wouldn't this be a simpler method? Basically its the same thing as yours, but cleaned up?
Well, oppy, I already fixed it, but thanks though ♥
Of course you fixed it. You're a magnificent bastard. ♥
This is what I had to do: `Dim srtb As New SyntaxHighlighter.SyntaxRichTextBox` ` Dim TabPage As New TabPage` ` TabPage.Controls.Add(srtb)` ` srtb.Dock = DockStyle.Fill` ` TabPage.Text = "New Document"` ` TabControl1.TabPages.Add(TabPage)`
Join our real-time social learning platform and learn together with your friends!