In Visual c# Express Edition, is it possible to make some (but not all) items in a ListBox bold? I can\'t find any sort of option for this in the API.
A more generic example that uses sender, and actually respects foreground color (if the item is selected, for example, or the user uses some another color set, where black foreground color is not really readable) and current ListBox font:
private void listBoxDrawItem (object sender, DrawItemEventArgs e)
{
Font f = e.Font;
if (e.Index == 1) //TODO: Your condition to make text bold
f = new Font(e.Font, FontStyle.Bold);
e.DrawBackground();
e.Graphics.DrawString(((ListBox)(sender)).Items[e.Index].ToString(), f, new SolidBrush(e.ForeColor), e.Bounds);
e.DrawFocusRectangle();
}
You need to have DrawMode set to OwnerDrawFixed (for example, in designer).