表单加载时的图像视图 [英] Image view on form load
本文介绍了表单加载时的图像视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用picturebox上的代码在表单加载时显示图像.
i want to show image on form load using code on picturebox.
推荐答案
请参见以下代码作为参考:
See this code as a reference:
private void Form1_Load(object sender, EventArgs e)
{
pictureBox1.Image = new Bitmap("C:\\Temp\\Test.jpg");
}
尝试此代码
创建这样的文件夹
D:\\您的项目名称\ bin \ Debug \ images并将您的映像放在此处.
然后在下面的代码中写
try this code
create folder like this
D:\\Yourprojectname\bin\Debug\images and put your image here.
then write below piece of code
private void Form2_Load(object sender, EventArgs e)
{
pictureBox1.Image = Image.FromFile(Application.StartupPath + "\\images\\yourimage.jpg");
}
我的答案与JF2015和D-Kishore的答案相同相同,但是我将把照片放在参考资料中.
然后我可以这样写:
My answer is same as those by JF2015 and D-Kishore, but I would put my picture in Resources.
Then I could write something like this:
private void MyForm_Load(object sender, EventArgs e)
{
myPictureBox.Image = Properties.Resources.MyPicture;
}
这篇关于表单加载时的图像视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文