如何在Windows窗体上获取员工图像?

编程入门 行业动态 更新时间:2024-10-12 05:55:01
本文介绍了如何在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窗体上获取员工图像?

本文发布于:2023-10-08 01:10:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471069.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:窗体   图像   员工   如何在   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!