How to register a global hotkey for your application in C#

How to register a global hotkey for your application in C#

Register a hotkey for your application that can be triggered even if your form is minimized and does not have focus. More »

Visual Studio 2013

Visual Studio 2013

Visual Studio 2013 is now available. Make sure to upgrade to the latest version of Visual Studio. More »

How to download a file in C# (progressbar and download speed)

How to download a file in C# (progressbar and download speed)

Learn how to download files in C# while displaying the percentage and the download speed. More »

UDP hole punching implementation in C#

UDP hole punching implementation in C#

Learn how to implement UDP hole punching so you can make your clients life a lot easier by not forcing them to open ports on their end. More »

 

ListBox selected item custom background and text color

This snippet will allow you to set a custom color for your ListBox’s selected item background as well as the selected items text color.

First make sure that your ListBox’s DrawMode is set to OwnerDrawFixed. This can either by done in the controls properties window or by calling listBox1.DrawMode = DrawMode.OwnerDrawFixed;

Then we need to handle the ListBox’s DrawItem event which is where we will be doing the changes to the selected items.

This will be our end result:
ListBox selected item custom colors

Feel free to play with the colors to achieve a look you like.

Share on FacebookTweet about this on TwitterShare on Google+Share on StumbleUponShare on LinkedInShare on RedditPin on PinterestShare on TumblrDigg thisPrint this pageEmail this to someone

3 Responses to ListBox selected item custom background and text color

  1. craig says:

    great code. this works great for me.

    thanks

  2. cabina says:

    Thank you very much, perfect code !

  3. qwe says:

    Thanks. Thanks. Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *