首先帮助的这个请修改:
If e.Col.Name =
"进度" AndAlso e.Row.IsNull("进度") = False Then
e.StartDraw()
Dim Width As Integer = (e.Width - 2 )* e.Row("进度") \ 100
If e.Row("进度") = 100 Then
e.Graphics.FillRectangle(Brushes.Green,e.x + 1,e.y + 1, Width, e.Height - 2)
Else
e.Graphics.FillRectangle(Brushes.Red,e.x + 1,e.y + 1, Width, e.Height - 2)
End If
e.EndDraw()
End If
这边的 Width 应该是 e.width
帮助的主题: 在单元格中直接绘图
是这样的 我发现一个错误 这个错误检查了很久都没有检查出来,今日上午无意发现.
我在窗口表的表事件中的这个事件(DrawCell事件)放入下面这段代码:
If e.Row.Equals(e.Table.Current) Then
e.StartDraw()
Dim _GradientBrush As System.Drawing.Drawing2D.LinearGradientBrush
_GradientBrush = New System.Drawing.Drawing2D.LinearGradientBrush(e.Bounds, Color.Green, Color.White, 90)
'e.Graphics.FillRectangle(e.Col._GradientBrush, e.Bounds.X + 2, e.Bounds.Y + 2, x, e.Bounds.Height - 4)
e.Graphics.FillRectangle(_GradientBrush, e.X + 2, e.Y + 2, e.Width - 3, e.Height - 4)
e.EndDraw()
End If
这个代码可以将当前行直接绘制成一个2D渐变的颜色.
然后做了一个按钮,按钮的代码是:
Tables(e.form.Name & "_Table1").AutoSizeCols() '窗口表所有列 自动列宽
结果一个错误发生:
.NET Framework 版本:2.0.50727.5448
Foxtable 版本:2014.5.12.1
错误所在事件:表,窗口1_Table1,DrawCell
详细错误信息:
调用的目标发生了异常。
矩形“{X=0,Y=0,Width=0,Height=0}”的宽度或高度不能等于零。
*************************************************************************************************************************
为了检测这个错误,我将帮助的这句代码放入绘制事件:
If e.Row.Equals(e.Table.Current) Then
e.StartDraw()
e.Graphics.FillRectangle(Brushes.Green,e.x + 1,e.y + 1, e.Width, e.Height - 2)
e.EndDraw()
End If
但是按钮执行且没有发生问题.
我想问的是同样的是采取了GDI+的做法 为啥会有这个错误产生?
[此贴子已经被作者于2014-6-8 12:18:17编辑过]