TabControl Hangs when adding new tab

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I'm hoping someone can help me. I am adding a new tab at runtime but not
making it the selectedindex. I am adding controls and setting color of the
tab before adding it to the tabcontrol. After I add it is shows up fine but
when I click on it to make it the active tab it seems to have trouble
painting it. Just the tab changes to white but the main part of the tab
remains the same as the prior tab and then the app hangs.

If I add the tab and make it the selected tab it works great. But I want to
add it and the controls without making it selected and have the user click to
it.

thanks for any help,

Rob
 
For those without mind reading skills here is the vb.net code:
Private Function AddNewTab(ByVal person As String, ByVal opentab As
Boolean) As Integer

Dim newtab As New TabPage
Dim newdisplay As New TextBox
Dim placeit As Point

newtab.Text = person
placeit = newdisplay.Location
placeit.X = 0
placeit.Y = 0
newdisplay.Location = placeit
newdisplay.Multiline = True
newdisplay.Height = 152

newdisplay.Width = 230
newdisplay.ScrollBars = ScrollBars.Vertical
newdisplay.BackColor = Color.FromArgb(255, 255, 192)

newtab.Controls.Add(newdisplay)

tabtalkto.TabPages.Add(newtab)

conversation(tabtalkto.TabPages.Count - 1).displaytext = newdisplay
conversation(tabtalkto.TabPages.Count - 1).user = person

If opentab Then
tabtalkto.SelectedIndex = tabtalkto.TabPages.Count - 1
end if

AddNewTab = tabtalkto.TabPages.Count - 1
end function
 
Back
Top