70sCommander
70sCommander

Reputation: 948

Is it Possible to set the height smaller than 21 pixels for the System.Windows.Forms.Combobox-Control

Hello Community,

i've a problem with the height of the System.Windows.Forms.Combobox-Control. I can't change it. I want to use that to write an own implementation (owner drawn custom control).

The following code does not work for me (It's only to try). The height is still 21px!

public class TestBox : ComboBox
{
    public TestBox()
    {
        DropDownHeight = 15;
    }

    protected override Size DefaultSize
    {
        get
        {
            return new Size(15,15);
        }
    }

    protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
    {
        base.SetBoundsCore(x, y, 15, 15, specified);
    }
}

Please help me.

Regars, Marco

Upvotes: 1

Views: 1577

Answers (1)

serhio
serhio

Reputation: 28586

The ComboBox height should be resized based on the font that is assigned to it.

So, change the combo font. see another discussion on this subject.

ComboBox's MinimumSize property is coded like this:

public override Size MinimumSize
{
    get
    {
        return base.MinimumSize;
    }
    set
    {
        // can see that Height is not taken in consideration - is 0
        base.MinimumSize = new Size(value.Width, 0); 
    }
}

Upvotes: 4

Related Questions