List of Exercises

Color of ComoBox Selected Item in WinForms c#

	    
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Color_of_Combobox_Selected_Item
{
  public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();
     
      comboBox1.FlatStyle = FlatStyle.Popup;
      comboBox1.KeyPress += comboBox1_KeyPress;
      comboBox1.DropDown += new EventHandler(comboBox1_DropDown);
      comboBox1.DropDownClosed += new EventHandler(comboBox1_DropDownClosed);
      
    }
    private void comboBox1_KeyPress(object sender, KeyPressEventArgs e)
    {
      e.Handled = true;
    }
    void comboBox1_DropDownClosed(object sender, EventArgs e)
    {
      comboBox1.ForeColor = Color.Red;
      comboBox1.Font = new Font("Arial", 12, FontStyle.Bold);
    }

    void comboBox1_DropDown(object sender, EventArgs e)
    {
      comboBox1.ForeColor = Color.Black;
      comboBox1.Font = new Font("Microsoft Sans Serif", (float)8.25, FontStyle.Regular);
    }
  }
}
		
	 


Download the project of Visual Studio 2013 in DropBox Download


How to Change Color of ComoBox Selected Item in WinForms C#


Video Thumbnail