以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助] drawcell 代码优化问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=118065)

--  作者:81538475
--  发布时间:2018/4/24 11:50:00
--  [求助] drawcell 代码优化问题
现在希望如果在 指定路径找到图片,则显示图片,如果找不到,就显示预设好的一个叉叉图片。
但是下面的代码效率太低,会不停的计算。。导致很卡。有没有好的方法优化一下呢
If e.Col.name= "缩略图" Then
    e.StartDraw
    If e.Row("缩略图") > "" Then
        If FileSys.FileExists("\\\\SERVER\\Foxtemp$\\"  & e.Row("缩略图")) Then
            e.Graphics.DrawImage(getimage( "\\\\SERVER\\Foxtemp$\\"  & e.Row("缩略图")), e.x + 3,e.y + 3, 50, 50) \'绘制第一个图标
        Else e.Graphics.DrawImage(getimage("Images\\Reject\\Reject.ico"), e.x + 3,e.y + 3, 50, 50)
        End If
    End If
    e.text = ""
    e.EndDraw
End If

--  作者:有点甜
--  发布时间:2018/4/24 12:19:00
--  

不用drawcell,直接给单元格设置图片,参考

 

Dim t As Table = Tables("表A")
Dim cs1 As C1.Win.C1FlexGrid.CellStyle = t.grid.Styles.Add("cs1")
cs1.BackgroundImage = getimage("d:\\test.jpg")
cs1.Display =  C1.Win.C1FlexGrid.DisplayEnum.ImageOnly
cs1.BackgroundImageLayout = C1.Win.C1FlexGrid.ImageAlignEnum.Stretch

t.grid.SetCellStyle(1, 1, cs1)


--  作者:81538475
--  发布时间:2018/4/24 14:28:00
--  
t.Cols("缩略图").index 我用这个获取这列的序列号,但是实际上是第八列,返回的值确实7。这个怎么处理呢
--  作者:81538475
--  发布时间:2018/4/24 14:52:00
--  
上面的问题解决了。另外一个问题又来了。。我是这样写的,出来的结果是 显示的所有的图片都会变成一样的。

Dim t As Table = Tables("XMFP")
For Each dt As Row In t.Rows
    Dim xl As Integer=  dt.Index + 1
    Dim yl As Integer=  t.Cols("缩略图").Index + 1
    If dt("缩略图") > ""  Then
        Dim cs1 As C1.Win.C1FlexGrid.CellStyle = t.grid.Styles.Add("cs1")
        cs1.BackgroundImage = getimage( "\\\\SERVER\\Foxtemp$\\"  & dt("缩略图"))
        cs1.Display =  C1.Win.C1FlexGrid.DisplayEnum.ImageOnly
        cs1.BackgroundImageLayout = C1.Win.C1FlexGrid.ImageAlignEnum.Stretch
        t.grid.SetCellStyle(xl,yl, CS1)
        ’Output.Show("\\\\SERVER\\Foxtemp$\\"  & dt("缩略图"))
        
    End If
Next


--  作者:有点甜
--  发布时间:2018/4/24 14:54:00
--  
Dim t As Table = Tables("XMFP")
For Each dt As Row In t.Rows
    Dim xl As Integer=  dt.Index + 1
    Dim yl As Integer=  t.Cols("缩略图").Index + 1
    If dt("缩略图") > ""  Then
        Dim cs1 As C1.Win.C1FlexGrid.CellStyle = t.grid.Styles.Add(dt("_Identify"))
        cs1.BackgroundImage = getimage( "\\\\SERVER\\Foxtemp$\\"  & dt("缩略图"))
        cs1.Display =  C1.Win.C1FlexGrid.DisplayEnum.ImageOnly
        cs1.BackgroundImageLayout = C1.Win.C1FlexGrid.ImageAlignEnum.Stretch
        t.grid.SetCellStyle(xl,yl, CS1)
        \'Output.Show("\\\\SERVER\\Foxtemp$\\"  & dt("缩略图"))       
    End If
Next

--  作者:81538475
--  发布时间:2018/4/24 15:03:00
--  
多谢了。还有个问题就是这个代码放在哪里呀。。。我放在afterload 不起作用
--  作者:有点甜
--  发布时间:2018/4/24 15:05:00
--  
可以写到AfterOpenProject事件,如果你修改了缩略图列的值,你还要在datacolchanged事件修改那一行的图片。类似2楼。
--  作者:81538475
--  发布时间:2018/4/24 15:06:00
--  
afteropen试过 了。。重新开项目的话,还是没有,只有个名字。
--  作者:有点甜
--  发布时间:2018/4/24 15:07:00
--  
以下是引用81538475在2018/4/24 15:06:00的发言:
afteropen试过 了。。重新开项目的话,还是没有,只有个名字。

 

不可能。只要执行过一次,就肯定没问题。

 

上传实例测试。


--  作者:81538475
--  发布时间:2018/4/24 15:11:00
--  
我新建的项目确实没有问题。。我在看下我这个哪里冲突了。