This class is derived from the .NET
ComboBox class. It provides coloring and stylish customization to change the appearance of
ComboBox's border and drop down button. An independent set of properties can be customized for both the
LostFocus statuses. These properties are customizable from within the designer.
ComboBox control provided by .NET 2.0 Framework is very limited in the ability to customize the appearance. A lot of people have created their own custom made
ComboBox instead of deriving from the
ComboBox from .NET Framework. It might be due to the
OnPaint function of the .NET
ComboBox being inaccessible to the text box area of the
ComboBox. You can allow overriding of the
OnPaint function by using this statement in the constructor:
public CustomComboBox() : base()
An alternative to re-drawing the
ComboBox control is by overriding the
WndProc function. However this approach can be significantly complicated to many beginners of C#, .NET or Win32 programming, especially when they want to continually select the suitable color and style to match the design of their application.
This project is extended from the existing project, "Making Standard ComboBox appear flat" contributed by Fadrian Sudaman. I am impressed with what has been done by Fadrian Sudaman to draw on top of .NET
ComboBox control by using
Using the code
This class inherits from .NET
Instead of using:
ComboBox cboDemo = new ComboBox();
You can use:
ComboBox cboDemo = new CustomComboBox();
CustomComboBox cboDemo = new CustomComboBox();
To use this class, reader needs to understand the standard functions, properties and events of .NET
ComboBox, and a few new properties created in this inherited class.
Points of Interest
I have spent a lot of time to fix the flickering problem of this inherited control. I cut off a lot of unnecessary codes and simplified out the overridden
WndProc function. I also changed the several "
OnEvent" function and moved the
Invalidate() to before
It still does flicker, especially if I set my video acceleration to None. However, I believe this should have minimized flickering into an acceptable level.
Ng Pei Jiun, Eugenis, graduated from National University of Singapore. After worked for one year as VB .NET and C# .NET programmer, I had decided to do freelancing in order to experience more about SDLC and Project Management.
I am currently unemployed and having intermediate skill in C# .NET programming.