.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

Home >> Articles >> Windows Application >> Post New Resource Bookmark and Share   

 Subscribe to Articles

How to make ComboBox highlight color to none?

Posted By:Jean Paul       Posted Date: February 24, 2011    Points: 100    Category: Windows Application    URL: http://www.dotnetspark.com  

How to make ComboBox highlight color to none in windows application programatically

In some forums I have seen developers wanted to change the selected color (usually Blue) of ComboBox to normal background color.  I would like to add the code for following.

Custom Drawing

The method used for accomplishing this is Custom Drawing.


1.       Create a new windows application and place a combo box on the form


2.       Set the property DrawMode to OwnerDrawVariable


3.       On the combo box DrawItem event, add the following code:


private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)


    ComboBox combo = sender as ComboBox;


    e.Graphics.FillRectangle(new SolidBrush(combo.BackColor), e.Bounds);

    e.Graphics.DrawString(combo.Items[e.Index].ToString(), e.Font, new

        SolidBrush(combo.ForeColor), new Point(e.Bounds.X, e.Bounds.Y));



Testing the Application

You can add some test data items to the combox and run the application.

Now you can see that eventhough the mouse is on the dropdown list area the highlight color is not there.

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend