Hy! I would like to make a logging system with a listbox, that highlights some of my lines, depends on my will :P So, if I have 4 kind of reporting, like, general, warning, error, debug.
I add with somelistbox.Items.Add("Starting"); <-- I would like to drawn this as grey somelistbox.Items.Add("Error!"); <-- I would like to drawn this as red But there is no way to do it, because I dont want to color my lines , based on item number. I want to color them based on logtype.
So I would like to add a new thing, like typeoflog, but I dont know how to do it. I mean somelistbox.Items.Add("Error!",Type.Error);
I've got this code, which colors items , depends on item number, but Thats not what I'm looking for.
private void general_log_DrawItem(object sender, DrawItemEventArgs e)
{
e.DrawBackground();
Brush myBrush = Brushes.Black;
switch (actualLogType)
{
case LogTypes.General:
myBrush = Brushes.Black;
break;
case LogTypes.Warning:
myBrush = Brushes.Orange;
break;
case LogTypes.Error:
myBrush = Brushes.Purple;
break;
case LogTypes.Debug:
myBrush = Brushes.AntiqueWhite;
break;
}
e.Graphics.DrawString(((ListBox)sender).Items[e.Index].ToString(),
e.Font, myBrush, e.Bounds, StringFormat.GenericDefault);
e.DrawFocusRectangle();
}