C# winform change selected tabcontrol image -


i have winform application written in c#. had imagelist in winform , have tabcontrol , each of tab assign image icon tab changing imageindex.

however have 1 image each tab , want them change image selected tab (like highlighted image active one). have idea add images imagelist (both active , inactive images) , change imageindex of selected tab. not sure how in practical.

here current codes can come with:

inside selectedindexchange event, have function:

foreach (tabpage tab in tabcontrol1)  {     if (tab.index == tabcontrol1.selectedindex) { <---how index?         tab.imageindex = tab.index + tabcontrol1.tabcount;     } else {         tab.imageindex = tab.index;     } } 

i came solution

for (int i=0; i<tabcontrol1.tabpages.count; i++)         {             if (tabcontrol1.tabpages[i] == tabcontrol1.selectedtab)             {                 tabcontrol1.tabpages[i].imageindex = + tabcontrol1.tabpages.count;             }             else             {                 tabcontrol1.tabpages[i].imageindex = i;             }         } 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -