C# winfrom ComboBox 调整下拉菜单的高度

1.设置属性

            // 1、属性设置 DrawMode ->OwnerDrawVariable
            this.cboBoxPostID.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
            this.cboBoxPostID.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.cboBoxPostID_DrawItem);

2.DrawItem事件

     private void cboBoxPostID_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }
            e.DrawBackground();
            e.DrawFocusRectangle();
            e.Graphics.DrawString(cboBoxPostID.GetItemText(cboBoxPostID.Items[e.Index]).ToString(), e.Font, new SolidBrush(e.ForeColor), e.Bounds.X, e.Bounds.Y + 3);
        }
原文地址:https://www.cnblogs.com/yimeishui/p/5803920.html