---
title: "C# winform change selected tabcontrol image"  
description: "C# winform change selected tabcontrol image"  
author: "Anonymous User"  
published: 2013-05-13  
updated: 2013-05-13  
canonical: https://www.mindstick.com/forum/881/c-sharp-winform-change-selected-tabcontrol-image  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# C# winform change selected tabcontrol image

Hi [Expert](https://www.mindstick.com/articles/13120/an-expert-financial-advice-will-improve-your-finances)!\
I have a winform [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) written in C#. I had an imageList in my winform and I have a tabcontrol and each of the tab I assign a [image](https://www.mindstick.com/articles/23551/an-investigate-distinctive-seafood-restaurant-for-your-image-stamp-character) 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](https://answers.mindstick.com/qa/97113/why-does-an-active-ftp-not-work-with-network-firewalls) one). I have an \
idea to add all [images](https://www.mindstick.com/interview/1067/what-is-the-php-predefined-variable-that-tells-the-what-type-of-images-that-php-support) 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](https://www.mindstick.com/articles/167719/marquee-hire-benefits-of-event-lighting-hire-london), I have a [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server):\
[foreach](https://www.mindstick.com/forum/33870/how-parallel-foreach-works-internally) (TabPage tab in tabControl1) { if (tab.[index](https://www.mindstick.com/blog/198/index-in-sql-server) == tabControl1.SelectedIndex) { <---how to get the index? tab.imageIndex = tab.index + tabControl1.TabCount; } else { tab.imageIndex = tab.index; }}\
Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)!

## Replies

### Reply by AVADHESH PATEL

Hi John!\
You can try as following\
for (int i=0; i<tabControl1.TabPages.Count; i++) { if (tabControl1.TabPages[i] == tabControl1.SelectedTab) { tabControl1.TabPages[i].ImageIndex = i + tabControl1.TabPages.Count; } else { tabControl1.TabPages[i].ImageIndex = i; } }\
I hope it helpful to you!\


---

Original Source: https://www.mindstick.com/forum/881/c-sharp-winform-change-selected-tabcontrol-image

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
