是否有可能更改所选(不在下拉列表中的)项的外观?
combobox.ForeColor 仅更改下拉列表中所有项的文本颜色。
编辑: 变体如下,我们的是
public static void CBoxDrawItem(object sender, DrawItemEventArgs args)
{
var box = sender as ComboBox;
if (box == null || args.Index < 0 || args.Index >= box.Items.Count)
return;
e.DrawBackground();
var data = box.Tag as ControlData;
var color = (args.State & DrawItemState.ComboBoxEdit) == 0 || data == null || !data.IsInDefaultState
? e.ForeColor : GetDefaultColor(e.ForeColor);
using (var brush = new SolidBrush(color))
{
args.Graphics.DrawString(box.Items[args.Index].ToString(), args.Font, brush, args.Bounds.X, args.Bounds.Y);
}
args.DrawFocusRectangle();
}