初始化combox
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
comboBox1.ItemHeight = 25; // 设置 combox 的行高
comboBox1.DrawMode = DrawMode.OwnerDrawVariable;
添加 DrawItem 事件
private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
{
if (e.Index < 0)
return;
e.DrawBackground();
e.DrawFocusRectangle();
// 调整文字文字位置, 主要调整 Y (e.Bounds.Y)
e.Graphics.DrawString(comboBox1.Items[e.Index].ToString(), e.Font, new SolidBrush(e.ForeColor), e.Bounds.X, e.Bounds.Y + 5);
}
效果