Foxtable(狐表)用户栏目专家坐堂 → 添加图片还是有问题


  共有1627人关注过本帖树形打印复制链接

主题:添加图片还是有问题

帅哥哟,离线,有人找我吗?
天蝉一下
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:74 积分:605 威望:0 精华:0 注册:2016/6/13 18:16:00
添加图片还是有问题  发帖心情 Post By:2017/6/12 13:53:00 [只看该作者]

Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")
Dim dt As DataTable
lvw.Rows.Clear() '清除原来的行
lvw.Images.Clear() '清除原来的图片
lvw.View = ViewMode.SmallIcon '用小图标模式
Dim cmd As new sql command
cmd.Connec ti
cmd.Comman dText="select * fr o m {审核管理} where 审核编号='" & lst.Table.Current("计划编码") & "' and 审批意见='同意'"
dt=cmd.Ex ecut eR eader
Dim fd2 As String
For Each dr As DataRow In dt.DataRows '列出所有
   If dr("签字位置") IsNot Nothing Then
     fd2 = ProjectPath & "Attachments\Images\" & dr("审核人账号") & "100user.png"
         If FileSys.FileExists(fd2)=False Then '如果指定的文件存在
Dim ftp1 As New FtpClient
ftp1.Host="192.168.254.202"
ftp1.Port="21"
ftp1.Account = "fox"
ftp1.Password = "*******"
        If ftp1.FileExists(dr("签字位置")) Then '如果文件存在
            '     FileSys.DeleteFile(fd2,2,2) '则彻底删除之
            '    End If
            ftp1.Download(dr("签字位置"),fd2,False)
            ' FileSys.CopyFile(dr("大头像"),fd2 ,True)
    End If
   End If
'For Each dr As DataRow In dt.DataRows
 lvw.Images.AddSmallImage(ProjectPath & "Attachments\Images\" & dr("审核人账号") & "100user",ProjectPath & "Attachments\Images\" & dr("审核人账号") & "100user.png") '添加小图标
    Dim r As  WinForm.ListViewRow =  lvw.Rows.Add() '增加一行
    r.Text = dr("审批时间") '指定标题
    r.ImageKey = ProjectPath & "Attachments\Images\" & dr("审核人账号") & "100user.png" '指定图标键值
End If
Next

这段代码提示“未将对象引用设置到对象的实例”

 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/6/12 14:09:00 [只看该作者]

 如果图片不存在,你怎么处理?

 

For Each dr As DataRow In dt.DataRows '列出所有
    If dr("签字位置") IsNot Nothing Then
        fd2 = ProjectPath & "Attachments\Images\" & dr("审核人账号") & "100user.png"
        If FileSys.FileExists(fd2)=False Then '如果指定的文件存在
            Dim ftp1 As New FtpClient
            ftp1.Host="192.168.254.202"
            ftp1.Port="21"
            ftp1.Account = "fox"
            ftp1.Password = "*******"
            If ftp1.FileExists(dr("签字位置")) Then '如果文件存在
                '     FileSys.DeleteFile(fd2,2,2) '则彻底删除之
                '    End If
                ftp1.Download(dr("签字位置"),fd2,False)
                ' FileSys.CopyFile(dr("大头像"),fd2 ,True)
            End If
            lvw.Images.AddSmallImage(ProjectPath & "Attachments\Images\" & dr("审核人账号") & "100user",ProjectPath & "Attachments\Images\" & dr("审核人账号") & "100user.png") '添加小图标
            Dim r As  WinForm.ListViewRow =  lvw.Rows.Add() '增加一行
            r.Text = dr("审批时间") '指定标题
            r.ImageKey = ProjectPath & "Attachments\Images\" & dr("审核人账号") & "100user.png" '指定图标键值

        Else

           '你怎么处理?
        End If
    End If
Next


 回到顶部
帅哥哟,离线,有人找我吗?
天蝉一下
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:74 积分:605 威望:0 精华:0 注册:2016/6/13 18:16:00
  发帖心情 Post By:2017/6/12 14:34:00 [只看该作者]

For Each dr As DataRow In dt.DataRows '列出所有
    If dr("签字位置") IsNot Nothing Then
        fd2 = ProjectPath & "Attachments\Images\" & dr("审核人账号") & "100user.png"
        If FileSys.FileExists(fd2)=False Then '如果指定的文件存在
            Dim ftp1 As New FtpClient
            ftp1.Host="192.168.254.202"
            ftp1.Port="21"
            ftp1.Account = "fox"
            ftp1.Password = "*******"
            If ftp1.FileExists(dr("签字位置")) Then '如果文件存在
               ftp1.Download(dr("签字位置"),fd2,False)
                End If

通过判断服务器上是否存在dr("签字位置")的图片,如果有,下载到本地,文件名为fd2
            lvw.Images.AddSmallImage(ProjectPath & "Attachments\Images\" & dr("审核人账号") & "100user",ProjectPath & "Attachments\Images\" & dr("审核人账号") & "100user.png") '添加小图标
            Dim r As  WinForm.ListViewRow =  lvw.Rows.Add() '增加一行
            r.Text = dr("审批时间") '指定标题
            r.ImageKey = ProjectPath & "Attachments\Images\" & dr("审核人账号") & "100user.png" '指定图标键值

        Else

           '你怎么处理?
        End If
    End If
Next


为什么显示的图片是空的,我用的png格式,帮助里面是ico有什么区别吗



 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/6/12 14:56:00 [只看该作者]

For Each dr As DataRow In dt.DataRows '列出所有
    If dr("签字位置") IsNot Nothing Then
        fd2 = ProjectPath & "Attachments\Images\" & dr("审核人账号") & "100user.png"
        Dim ftp1 As New FtpClient
        ftp1.Host="192.168.254.202"
        ftp1.Port="21"
        ftp1.Account = "fox"
        ftp1.Password = "*******"
        If ftp1.FileExists(dr("签字位置")) Then '如果文件存在
            ftp1.Download(dr("签字位置"),fd2,False)
        End If
        ftp1.close
        If FileSys.FileExists(fd2)=False Then '如果指定的文件存在
            lvw.Images.AddSmallImage(fd2, fd2) '添加小图标
            Dim r As  WinForm.ListViewRow =  lvw.Rows.Add() '增加一行
            r.Text = dr("审批时间") '指定标题
            r.ImageKey = fd2
        Else
            msgbox("不存在对应的图片文件")
        End If
    End If
Next

 回到顶部