以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]单元格百分比绘图  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=135414)

--  作者:天一生水
--  发布时间:2019/5/25 22:23:00
--  [求助]单元格百分比绘图
帮助示例中的单元格绘图,如果把单元格的数字变为百分比,需要怎样改动代码?

\'\'\'
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)
    ElseIf 90% < e.Row("进度") < 100% Then
        e.Graphics.FillRectangle(Brushes.Red,e.x + 1,e.y + 1, Width, e.Height - 2)
    Else  
        e.Graphics.FillRectangle(Brushes.blue,e.x + 1,e.y + 1, Width, e.Height - 2)
    End If
    e.EndDraw()
End If


图片点击可在新窗口打开查看此主题相关图片如下:截屏图片.jpg
图片点击可在新窗口打开查看


--  作者:有点甜
--  发布时间:2019/5/26 13:59:00
--  

参考

 

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("进度") = 1 Then
        e.Graphics.FillRectangle(Brushes.Green,e.x + 1,e.y + 1, Width, e.Height - 2)
    ElseIf 0.9 <= e.Row("进度") AndAlso e.Row("进度") < 1 Then
        e.Graphics.FillRectangle(Brushes.Red,e.x + 1,e.y + 1, Width, e.Height - 2)
    Else 
        e.Graphics.FillRectangle(Brushes.blue,e.x + 1,e.y + 1, Width, e.Height - 2)
    End If
    e.EndDraw()
End If

 


--  作者:天一生水
--  发布时间:2019/5/27 16:29:00
--  

我把[进度]列属性设置为小数,在表的datachanging事件写代码:

DataTables("表A").DataCols("进度").SetFormat("#0.%")

 

但是,每次打开窗口,窗口表的列值都是小数。只有出现新数据,[进度]列的值才会变成百分数。

应该怎样设计[进度]列?

谢谢!


--  作者:有点甜
--  发布时间:2019/5/27 17:22:00
--  

 

代码写到窗口afterLoad事件,不行?