I recently had to use a combobox with the flat style. I really dont like to do it because it renders flat, but without a border. It seems that this control is not a .net instrinsic control, but rather a wrapper around the combobox used within Windows itself. Because of this, it seems quite difficult to owner draw a solution. I have seen a few solutions with lots of code, but even those didnt work flawlessly for me. I even went as far as putting my own code in the paint event, and maually drawing a border around the rectangle of the control, but I was unahppy with the results. Because its not a .net control, it’s just not flexable enough for me. I know I’m picky, but I like my controls like my women, flexable <grin>. So I put up with the borderless thing.
When using the combobox with the flatstyle set to flat and anchoring the combobox to grow with a form, the combobox has trouble rendering. You often get the following:
As you can see, the combo renders the flatstyle properly the first time, but after the anchor stretches the combobox, the rendering gets all jacked up. This seems to be a bug in the way the control works with the underlying combobox control from Windows itself.
If you need a workaround, I found the following to work well. It’s not a bug fix, but it does work, and thats what I am all about.
Hook up a Resize event and put the following in it:
private void _cboMyCombo_Resize(object sender, EventArgs e)
{
_cboMyCombo.Refresh();
}
Enjoy!
-Jeff
blog:www.savij.com
