I am sure that there is something simple that I am missing, but I must admit that at this moment I am at a loss.
I programmatically add TabItems to my main TabControl, one for each account that the user wants to open. Before creating and adding a new TabItem, I would like to check if the user is open on another tab. I don’t want the end to open two identical tabs.
Here is the code I originally wrote. Hope this gives you an idea of what I'm trying to accomplish.
if (tab_main.Items.Contains(accountNumber))
{
tab_main.SelectedIndex = tab_main.Items.IndexOf(accountNumber);
}
else
{
Search s = new Search(queryResults, searchText);
TabItem tab_search = new TabItem();
tab_search.Header = searchString;
tab_search.Name = accountNumber;
tab_search.Content = s;
tab_main.Items.Add(tab_search);
}
, . WinForms TabControl TabPages ContainsKey, TabPage. , Items.Contains(), !
.
!