天天看點

C# WinForm comboBox控件設定間隔

comboBox控件設定上下值間隔

設定屬性DrawMode = OwnerDrawVariable

建立事件DrawItem

private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }
            e.DrawBackground();
            e.DrawFocusRectangle();
            e.Graphics.DrawString(comboBox1.Items[e.Index].ToString(), e.Font, new SolidBrush(e.ForeColor), e.Bounds.X, e.Bounds.Y + 4);
        }