3

I've added some TTabItem(s) to a TTabControl at runtime. But I can not remove them.

the code I use to create items:

tbi := TTabItem.Create(tbc);
tbi.Parent := tbc;
tbi.Index := tbc.TabCount - 1;

How can I remove those tab items?

Peter
  • 2,977
  • 1
  • 17
  • 29
hdayi
  • 423
  • 2
  • 4
  • 13

1 Answers1

8

You can go ahead and directly call either tbi.DisposeOf or tbc.Tabs[ItemIndex].DisposeOf.

The call to TTabItem.DisposeOf will run the destructor code, ensuring a clean removal from the internal tab list.

Peter
  • 2,977
  • 1
  • 17
  • 29
  • It does work, but I run the code on Android, with couple times dispose tabItem, access violation pops up. I am trying to figure it out. – Dennies Chang Dec 05 '17 at 07:49