如何在Windows窗体上获取员工图像? [英] How Do I Get Employee Images On My Windows Form ?

查看:58
本文介绍了如何在Windows窗体上获取员工图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows窗体,

i希望在我打开时在他的表单上获得员工图像



i已将图像上传到有关employeeid名称的文件夹如何访问该图像?





i已经尝试了

i have a windows form ,
i want to get employees image on his form when i open that

i have images uploaded in a folder with name of employeeid how i can access that image ?


i have tried

Dim str As String
       str = "~/Uploads/" & ds.Tables(0).Rows(0)("id") & ".jpg"
       picEmpProfile.BackgroundImage = str









plz help



谢谢。





plz help

thank you.

推荐答案

所以......你看过互联网,抓住第一个看起来像解决方案的东西,当它不起作用时会感到惊讶吗?



我并不感到惊讶它不起作用:你所拥有的是基于Web的解决方案,而不是基于Winforms的解决方案。线索在路径中,对于基于Web的路径以〜开头,因为物理磁盘不能直接用于您,您必须相对于您的网站根目录。 Windows窗体应用程序不需要它。



因此,将PictureBox控件添加到窗体,并将其Image属性设置为您需要的图像:

So...you have looked at the internet, grabbed the first thing that looks like a "solution" and are surprised when it doesn't work?

I'm not surprised it doesn't work: what you have is a web based solution, not a Winforms based solution. The clue is in the path, which starts with "~" for web based paths because the physical disk is not available to you so directly and you have to go relative to you web site root. Windows Forms applications do not need that.

So, add a PictureBox control to your form, and set it's Image property to the image you need:
myPictureBox.Image = Image.FromFile(@"D:\Temp\MyPic.jpg");


picEmpProfile是PictureBox吗?如果是PictureBox,请使用以下代码:

Is picEmpProfile a PictureBox? If it's a PictureBox use the following code:
picEmpProfile.Image = Image.FromFile(str)



这应该有效。


This should work.


这篇关于如何在Windows窗体上获取员工图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆