TabControl Hangs when adding new tab

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top