如何浏览图像? [英] How can browse image ?
本文介绍了如何浏览图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的问题是,我必须从系统上载一张图片并将其放在图片框中.请将可能的答案发送给我.
谢谢,
Viswanathan.M
Hi,
My question is,, I have to upload one image from my system and to place in picture box.Kindly send me the possible answer.
Thanks,
Viswanathan.M
推荐答案
Google [^ ]是你的朋友.
嘿!这是一个非常基本的知识,您在.Net平台中进行编码时应该了解这一点.您可以简单地使用OpenFileDialog
来提示用户从系统中打开文件.然后在获得确认后,可以使用FileDialog
类的FileName属性,该属性用于对包含文件名的字符串进行字符串化并将其分配给Image.FromFile()
函数.
hey! its a very basic thing which you should know about it when you are coding in .Net platform. whatever you can simply useOpenFileDialog
which is used to prompt the user to open a file from system. and then after getting confirmation you can use FileName property ofFileDialog
class which is used to string containing file name and assign it toImage.FromFile()
function.
OpenFileDialog obj = new OpenFileDialog();
if (obj.ShowDialog() == DialogResult.OK)
{
// you can use any one the way to display image in ImageControl
// pictureBox1.Image = Image.FromFile(obj.FileName);
// pictureBox1.ImageLocation = obj.FileName;
}
正如Marcus所建议的,我在互联网上搜索时发现了许多答案.
就像此 [
As Marcus suggested, I found a number of answers on doing a search on the internet.
Something as simple as this[^] should work.
这篇关于如何浏览图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文