ProgressBar text alignment in v5

The text in the progress bar is no longer aligned center to the control/cell (its aligned center to the actual value of the progress bar). This is even worse when the value is 0, as it doesn't show up at all.

I haven't modified the ProgressBar cells sample at all, yet it shows up like this.

Please let me know how to fix it.

Thanks.

progress.zip

2 Replies

HA haneefm Syncfusion Team June 6, 2007 09:23 PM UTC

Hi Ossama,

One way you can do this by handling the DrawCell event and draw center aligned progress value string using the e.Graphics.DrawString method. Below is a code snippet that show this task.

private void gridControl1_DrawCell(object sender, GridDrawCellEventArgs e)
{
if (e.Style.CellType == "ProgressBar")
{
e.Cancel = true;
e.Style.ProgressBar.TextVisible = false;
e.Renderer.Draw(e.Graphics, e.Bounds, e.RowIndex, e.ColIndex, e.Style);
Size size = e.Graphics.MeasureString(e.Style.ProgressBar.ProgressValue.ToString() + "%", e.Style.GdipFont).ToSize() ;
Rectangle rect = GridUtil.CenterInRect(e.Bounds,size);
e.Graphics.DrawString(e.Style.ProgressBar.ProgressValue.ToString() + "%", e.Style.GdipFont, new SolidBrush(e.Style.TextColor), rect);

}
}

Best regards,
Haneef


OA Ossama Alami June 7, 2007 12:04 AM UTC

Okay, I'll try that. But this looks like a bug, are you guys planning on fixing it?

Loader.
Up arrow icon