forum

Home / DeveloperSection / Forums / C# winform change selected tabcontrol image

C# winform change selected tabcontrol image

Anonymous User406313-May-2013
Hi Expert!

I have a winform application written in C#. I had an imageList in my winform and I have a tabcontrol and each of the tab I assign a image as icon for the tab by 

changing ImageIndex.

However they have only 1 image for each tab and I want them to change to another image for the selected tab (like another highlighted image for active one). I have an 

idea to add all images to the imageList (both active and inactive images) and change the imageIndex of the selected tab. But I am not sure how to do it in practical.

Here are my current codes that I can come up with:

Inside SelectedIndexChange event, I have a function:

foreach (TabPage tab in tabControl1) 
{
    if (tab.index == tabControl1.SelectedIndex) { <---how to get the index?
        tab.imageIndex = tab.index + tabControl1.TabCount;
    } else {
        tab.imageIndex = tab.index;
    }
}

Thanks in advance! 

Updated on 13-May-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By