0
我需要将DevExpress网格单元中的值的百分比表示为图。我可以使用DrawLine进行绘制,但是我的问题是一旦百分比值等于大于1,它将在此代码中被视为100%。请找到下面的代码,如截图所示,3.59应该显示小于8.35!请帮忙。DevExpress网格单元中的值图的百分比
private void CustomDrawCell(object sender, RowCellCustomDrawEventArgs args)
{
args.Appearance.DrawBackground(args.Graphics, args.Cache, args.Bounds);
if (column != null)
{
int penSize = args.Bounds.Height * 2/3;
double value = GetValue(); // This is the value against which I have to display the graph, its in %.
int left = args.Bounds.Left;
int middle = args.Bounds.Height/2 + args.Bounds.Top;
int width = args.Bounds.Width;
int right = (int)(left + width * value);
args.Graphics.DrawLine(new Pen(Color.Green, penSize), left, middle, right, middle);
}
args.Handled = true;
}
好像'right'应该是:int right =(int)(width *(value/100))。绘制线条的宽度应该相对于单元格宽度的宽度。 – 2015-02-08 23:32:42