Deleting Tabs from Tab Control

  • Thread starter Thread starter meh
  • Start date Start date
M

meh

Hi All;
After creating a new tab if I delete the tab I cannot close my app from the
X in the upper right of the window. NE1 have a clue why.
Tried stepping through the delete seems to work fine but I can not close the
app??????

I am creating a new Tab this way.....

ElseIf e.Button Is tbNewVol Then

Dim tp As New TabPage()

Dim lbl As New Label()

Dim cboBox As New ComboBox()

Dim tv As New TreeView()

Dim tb As New ToolBar()

tp.Controls.AddRange(New System.Windows.Forms.Control() {tv, cboBox, lbl,
tb})

' Set control's properties here.

tb.Dock = DockStyle.Right

tb.Buttons.AddRange(New System.Windows.Forms.ToolBarButton()
{Me.btnClrCombo, Me.tb2Sep1, Me.tbScratch, Me.tb2Sep2, Me.tbNewVol,
Me.tbSep3, Me.tbExpandAll, Me.tbCollapseAll, Me.tbSep4, Me.tbMailTo})

tb.Appearance = ToolBarAppearance.Flat

tb.ButtonSize.Height.Equals(16)

tb.ButtonSize.Width.Equals(16)

lbl.BorderStyle = BorderStyle.Fixed3D

lbl.Dock = DockStyle.Top

cboBox.Dock = DockStyle.Top

tv.Dock = DockStyle.Fill

tv.ContextMenu = mnuTreeContext

Me.TabControl.TabPages.Add(tp)

Dim tabCount As Integer = TabControl.Controls.Count

TabControl.SelectedIndex = TabControl.TabPages.IndexOf(tp)

TabControl.SelectedTab.Text = ("New Volume " & ((TabControl.TabCount() +
1) - 2))

CurrTree = tv

tb = ToolBar2

CurrCombo = cboBox

CurrLabel = lbl





I am deleting the Tab this way....
Private Sub tabMenuDelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles tabMenuDelete.Click

Dim Test As String

Test = TabControl.SelectedTab.Text()

TabControl.TabPages.Remove(TabControl.SelectedTab)

TabControl.Refresh()

End Sub
 
thx Herfried;

Yes it is that bug......been trying to figure out the
OnControlRemoved()

Do you know of any samples I might look at....I still don't understand the
..Net help it seems to tell me what this event is but not how to use
it........

tia
meh
 
If any one is interested the work around (fix) was

The tab I built had controls on it Label, ComboBox, TreeView....

If I delete the controls first then I can delete the TabPage with no
detrimental effects on the app. i.e. It closes like a champ.

Thx to all

meh

meh said:
thx Herfried;

Yes it is that bug......been trying to figure out the
OnControlRemoved()

Do you know of any samples I might look at....I still don't understand the
.Net help it seems to tell me what this event is but not how to use
it........

tia
meh

Herfried K. Wagner said:
from
close
 
Back
Top