Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 如果图像无效,则隐藏Picturebox_Vb.net_Image_Telerik_Report_Picturebox - Fatal编程技术网

Vb.net 如果图像无效,则隐藏Picturebox

Vb.net 如果图像无效,则隐藏Picturebox,vb.net,image,telerik,report,picturebox,Vb.net,Image,Telerik,Report,Picturebox,我正在使用Telerik报告工具创建报告,上面有一些图像。我使用来自客户端的URL在picturebox中显示图像,但在某些情况下,给定的URL无效,因此它将在报告中显示错误消息。我只想在图像不可用时隐藏picturebox,这样错误就不会出现在报告中。我怎么做?提前感谢:)在您的网站上进行网络请求。 例如: Public Sub Run() Dim myReportImage As Image = GetControl("ReportImage") myReportImage.

我正在使用Telerik报告工具创建报告,上面有一些图像。我使用来自客户端的URL在picturebox中显示图像,但在某些情况下,给定的URL无效,因此它将在报告中显示错误消息。我只想在图像不可用时隐藏picturebox,这样错误就不会出现在报告中。我怎么做?提前感谢:)

在您的网站上进行网络请求。 例如:

Public Sub Run()
    Dim myReportImage As Image = GetControl("ReportImage")
    myReportImage.Visible = CheckWebImage()
    ' or
    myReportImage.Enabled = CheckWebImage()
End Sub

Private Function CheckWebImage() As Boolean
    Dim url As New System.Uri("http://www.url.com/yourImage.jpg")
    Dim request As System.Net.WebRequest = System.Net.WebRequest.Create(url)
    Dim response As System.Net.WebResponse

    Try
        response = req.GetResponse()
        response.Close()
        request = Nothing
        Msgbox("Website Found!")
        Return True
    Catch ex As Exception
        request = Nothing
        Msgbox("Website not found. Check the url and internet connection")
        Return False
    End Try
End Sub

我得到一个错误,它说:无效的URI:无法确定URI的格式。这是什么意思?你能给你的url一个例子吗?它已经在工作了!您给定的代码完全正常工作,可能我昨天在对象事件序列方面遇到了一些问题,但我已经解决了。非常感谢你的帮助!它真的帮了我很多:D