Controlling height of dropdown listbox in OwnerDrawn combobox


Aravind Thoram

I am trying to create an owner drawn combo box wherein
the various items have different heights. So I am overriding
the OnMeasureItem method to set the ItemHeight. I am
drawing the ComboBox items in the OnDrawItem method.
When the number of items in the ComboBox is equal to 1
somehow the size of the drop down list box displayed is smaller than
the item height set by me. Even when the number of items
are greater than 1, I am not able to control the size of the drop down
list box that is displayed. I would be very much thankful if someone
could point out how I can control the size of the listbox that is

Thanks again in advance.

public Form1() {
this.comboBox1.DrawMode = DrawMode.OwnerDrawVariable;
this.comboBox1.IntegralHeight = false;
this.comboBox1.DrawItem +=new DrawItemEventHandler(ComboboxDrawItem);
this.comboBox1.MeasureItem += new

private void Form1_Load(object sender, System.EventArgs e) {

private void ComboboxDrawItem(object sender, DrawItemEventArgs e) {
if (-1 < e.Index) {
e.Graphics.FillRectangle(new SolidBrush(Color.Pink), e.Bounds.X,
e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
e.Graphics.DrawRectangle(new Pen(Color.Black), e.Bounds.X, e.Bounds.Y,
e.Bounds.Width-1, e.Bounds.Height-1);
SystemInformation.MenuFont, new SolidBrush(Color.Blue), e.Bounds);


private void MyOnMeasureItem(object sender,
System.Windows.Forms.MeasureItemEventArgs e) {
if (-1 < e.Index) {
e.ItemHeight = 35;

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question