An alternative is to use a ListView
with OwnerDraw
property true and respond to the DrawSubItem()
event. Drawing a progress bar is supereasy within the given rectangle e.Bounds
that is given in the event arguments using the already supplied e.Graphics
object.
Here is an example
private void lvUsers_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
if (e.ColumnIndex == 5)
{
e.DrawDefault = false;
Rectangle bounds = e.Bounds;
double pct = ...;
Rectangle fill = new Rectangle(
bounds.Left, bounds.Top,
(int)(pct * bounds.Width), bounds.Height);
using (LinearGradientBrush lg = ...)
{
e.Graphics.FillRectangle(lg, fill);
}
e.Graphics.DrawRectangle(Pens.Black, bounds);
...
}
else
{
e.DrawDefault = true;
}
}