windows形成combobox drawmode空列表

时间:2017-03-02 17:19:31

标签: c# winforms visual-studio

我有一个comboxbox设置为dropdownlist。我希望盒子有一个与灰色相对的白色背景,所以我将DrawMode设置为OwnerDrawFixed。
使用该设置,组合框的样式正确,但下拉列表中的列表现在为空。 前景设置为黑色,是什么导致了这个?

1 个答案:

答案 0 :(得分:0)

你需要自己绘制:

listBox.DrawMode = DrawMode.OwnerDrawFixed;
listBox.DrawItem += new DrawItemEventHandler(listBoxEvent);

private void listBoxEvent(object sender, 
System.Windows.Forms.DrawItemEventArgs e)
{
    // Draw the background of the ListBox control for each item.
    e.DrawBackground();
}

这是最低限度。