Blog

How to create an icon combobox with edaitable textbox for windows forms

Posted by Toshinobu Yamaguchi Blogs | Windows Forms C# Dec 06, 2010
Windows Forms / custom controls tips
Creating DropDownList style icon combobox(not editable) is not difficult.
You just set DrawMode to OwnerDrawFixed or OwnerDrawVariable,
then hook up the MeasureItem and DrawItem events.

On the other hand, creating icon combobox with editable text box is really difficult.
Because .net framework don't allow changing margin of editable portion
of combobox, and overriding OnPaint method of combobox.

I found good sample code to create an icon combobox with editable textbox.
He use Win32API to solve the problems. It's tough work!
The sample code and DLL are for .NET 1.1.
However, I think this technique could be applied for .net 3.0/3.5.
Does anyone know the code written by .net 3.0/3.5?

If you are using my combobox, creating editable combobox is easy.
You just set DrawMode and TextLeftMargin propeties, hook up DrawItem event and override OnPaint method.


iconcombo.jpg
--
post comment
     
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts