灰色列表框中的文本
Grey out text in a listbox
是否有一个类似于列表框但每个单独的项目可以有不同字体颜色的工具箱对象?我正在尝试创建一个 mod 管理器,并希望将那些已卸载的 mod 的文本显示为灰色。
试试这个:
private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
{
e.Graphics.DrawString(Convert.ToString(listBox1.Items[e.Index]), new Font("Aerial", 8), Brushes.Gray, new Point(0, 0));
e.DrawFocusRectangle();
}
为此,请将列表框的 DrawMode 更改为 OwnerDrawFixed。
此外,如果您想 select 组合框中的项目,请尝试这样的操作:
comboBox1.SelectedIndex = 0;
是否有一个类似于列表框但每个单独的项目可以有不同字体颜色的工具箱对象?我正在尝试创建一个 mod 管理器,并希望将那些已卸载的 mod 的文本显示为灰色。
试试这个:
private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
{
e.Graphics.DrawString(Convert.ToString(listBox1.Items[e.Index]), new Font("Aerial", 8), Brushes.Gray, new Point(0, 0));
e.DrawFocusRectangle();
}
为此,请将列表框的 DrawMode 更改为 OwnerDrawFixed。
此外,如果您想 select 组合框中的项目,请尝试这样的操作:
comboBox1.SelectedIndex = 0;