[不是问题] openfiledialog和picturebox [英] [Not a question] openfiledialog and picturebox

查看:71
本文介绍了[不是问题] openfiledialog和picturebox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我需要帮助。我必须在vb 2005中做一个项目。我只想创建一个包含按钮和图片框的表单。当我点击按钮时,它需要显示openfiledialog,所选图像应该上传到图片框中。我试图找到解决方案但是我找不到任何相关的答案。如果有人知道请帮助我。提前。



Maya

hi i need a help. i have to do a project in vb 2005. i just want to create a form which contains button and picture box. when i click on the button it needs to display the openfiledialog and the selected image should upload into the picture box. I have tried to find the soluion but however i couldn't find any related answer. if anyone knows pls help me. thanx in advance.

Maya

推荐答案

您不太可能找到所需内容的确切示例。



你的目标应该是逐个细分每个要求,并寻找如何做每个要求的例子。一旦你有了这些,你可以将它们结合起来使你的应用程序完整。



所以你的第一部分是从表格开始。



然后在表单上添加一个按钮。



然后在表单中添加一个图片框。



访问代码隐藏中的按钮单击事件,然后研究如何在按钮单击事件中打开openfiledialog控件。



现在搜索如何将图片从opendialog添加到图片框。
It is unlikely that you will find an exact example of what you need.

What your goal should be is to break down each requirement piece by piece and look for examples of how to do each one. Once you have those, you can combine them to make your application complete.

So your first part would be to start with a form.

Then add a button to your form.

Then add a picture box to your form.

Access the button click event in the code-behind and then research how to open an openfiledialog control in a button click event.

Now search how to add a picture from an opendialog to a picturebox.


我们不做你的作业:设置是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!



但是,这是一个非常非常简单的任务:最简单的只有三行代码!

1)创建一个新的OpenFileDialog

2)使用它的ShowDialog方法提示用户查找文件。

3)将PictureBox.Image属性设置为输出Image.FromFile方法,从OpenFile对话框传递FileName属性。
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

But, this is a really, really simple task: at it's simplest it's only three lines of code!
1) Create a new OpenFileDialog
2) Use it's ShowDialog method to prompt the user to find the file.
3) Set the PictureBox.Image property to the output of the Image.FromFile method, passing that the FileName property from the OpenFile Dialog.


你知道工程是什么吗?这不是发现,这是你的工作。如果每个人都只想找到任何相关的答案,谁会写一些代码?你需要编写代码,而不是搜索任何东西。



所以,这里有准确的说明:花一些时间,坐下来,写下代码根据你刚才描述的要求。你可能不需要专家知识;所有内容都是标准的MSDN文档。



这只是一小部分工作。如果你没有能力做这件事,没有答案会帮助你,因为它会让你为另一件小作品寻找另一个答案,阻止你做任何工作。



-SA
Do you have any idea what engineering is? This is not "finding", this is doing your job. If everyone would only try to "find any related answer", who would write some code? You need to write code, instead of searching for anything.

So, here is the exact instructions for you: get some time, sit down, and write down the code according to the requirements you just described. There is no "expert knowledge" you might need; everything is written is standard MSDN documentation.

This is just a tiny piece of work. If you are not capable of doing this piece, no "answer" will ever help you, because it would make you seeking for another answer for another tiny piece of work, blocking you from doing any work at all.

—SA


这篇关于[不是问题] openfiledialog和picturebox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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