Foxtable(狐表)用户栏目专家坐堂 → [求助] 在全局表事件 DrawCell 中,这段代码怎么不执行呢?


  共有2786人关注过本帖平板打印复制链接

主题:[求助] 在全局表事件 DrawCell 中,这段代码怎么不执行呢?

美女呀,离线,留言给我吧!
龙潭春早
  1楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:676 积分:4895 威望:0 精华:0 注册:2018/3/22 16:05:00
[求助] 在全局表事件 DrawCell 中,这段代码怎么不执行呢?  发帖心情 Post By:2020/2/6 17:24:00 [只看该作者]

一、之前,表不多、图片列也少,所以在两三个表的 DrawCell 事件中,加上了下面这段代码,一直使用正常:

Select Case e.Col.Name
Case "联系人照片"
e.StartDraw
If e.Row("联系人照片") > ""  Then
Dim Ls = e.Row.DataRow.Lines("联系人照片")
If FileSys.FileExists(projectPath & "RemoteFiles\" & Ls(0)) Then '如果文件存在
e.Graphics.DrawImage(getimage(projectPath & "RemoteFiles\" & Ls(0)), e.x + 5,e.y + 5, 90, 75)  ' 绘制第一个图标
End If
End If
e.text = ""
e.EndDraw

Case "产品图片"
e.StartDraw
If e.Row("产品图片") > ""  Then
Dim Ls = e.Row.DataRow.Lines("产品图片")
If FileSys.FileExists(projectPath & "RemoteFiles\" & Ls(0)) Then '如果文件存在
e.Graphics.DrawImage(getimage(projectPath & "RemoteFiles\" & Ls(0)), e.x + 5,e.y + 5, 100, 75)  ' 绘制第一个图片
End If
End If
e.text = ""
e.EndDraw
End Select

二、现在,表、图片列都多了,所以取消了在各个表中的代码,统一在全局表事件 DrawCell 中,加上了下面的代码。

但是不执行,什么原因呢?

For Each dc As DataCol In e.Table.DataTable.DataCols
If dc.ExtendType = ExtendTypeEnum.Images Then
e.StartDraw
If e.Row(dc.Name) > ""  Then
Dim Ls = e.Row.DataRow.Lines(dc.Name)
If FileSys.FileExists(projectPath & "RemoteFiles\" & Ls(0)) Then ' 如果文件存在
Dim strs As String = dc.Name
If strs.Contains("照片") Then
e.Graphics.DrawImage(getimage(projectPath & "RemoteFiles\" & Ls(0)), e.x + 5,e.y + 5, 90, 75)  ' 绘制第一个图标
ElseIf strs.Contains("图片") Then
e.Graphics.DrawImage(getimage(projectPath & "RemoteFiles\" & Ls(0)), e.x + 5,e.y + 5, 100, 75)  ' 绘制第一个图标
End If
End If
End If
e.text = ""
e.EndDraw
End If
Next

【说明】之前没有加 Dim strs As String = dc.Name直接使用的 dc.Name
因为代码不执行,才加了 strs 进行测试。

 回到顶部
总数 12 1 2 下一页