Search code examples
c#tabcontroltabitem

Adding tabItems-.Header to a List<T>


I have multiple TabItems in my TabControl; tabItem1, tabItem2, tabItem3...these are CloseableTabItem. if all tabitems are aktive, how can i add the tabItem.Header to a List<string>?


Solution

  •         List<string> listItems = new List<string>();
    
            foreach (TabItem item in tabControl1.Items)
            {
                if (item.IsEnabled)
                    listItems.Add(item.Header.ToString());
            }