fishmong3r
fishmong3r

Reputation: 1434

How to remove tab page using a string variable

I have a tab id in a string:

string tab_name = "tabPage1";

The tab id comes from an sql db, so it's not fixed as above. How to remove it at the program start? This is most likely incorrect:

tabControl1.TabPages.Remove(tab_name);

Upvotes: 0

Views: 372

Answers (1)

W0lfw00ds
W0lfw00ds

Reputation: 2086

Set a Name property to each TabPage:

tabControl1.TabPages[0].Name = "tabPage1";
// ...

Remove TabPage later by it's Name:

tabControl1.TabPages.RemoveByKey("tabPage1");

Upvotes: 2

Related Questions