如何编写代码控制 [英] how to write code control

查看:85
本文介绍了如何编写代码控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何编写代码以使用图片框控件从pc中的文件夹添加图片,并带有to按钮以在同一文件夹中提供下一个或上一个副本

how to write code to use picture box control to add picture from folder in pc with to button to give next or perviouse in same folder

推荐答案

大量的作业,我不会给你任何代码!
但是:
您将需要打开一个对话框来找到该文件夹​​: FolderBrowserDialog [ ^ ]或选择第一个文件: OpenFileDialog [ Image.FromFile [ ^ ]方法来加载图像.然后,您可以设置PictureBox控件的Image属性,它将显示它.

要移至下一个文件,您将需要读取文件夹中的所有文件名(请参见目录. GetAllFiles [ ^ ]方法).然后只需移至下一个文件,然后重复!

这并不困难,您一次只需要解决一个步骤,并确保每个步骤都有效,然后再进行下一步.
Since this smells heavily of homework, I won''t give you any code!
But:
You will need to open a dialog to find the folder: FolderBrowserDialog[^] or to select the first file: OpenFileDialog[^]
Then, you will need to store the file name you open somewhere (a class level string will be ideal) and use the Image.FromFile[^] method to load the image. You can then set the Image property of the PictureBox control and it will display it.

To move to the next file, you will need to read all the file names in the folder (see the Directory.GetAllFiles[^] method). Then just move to the next file, and repeat!

It''s not difficult, you just need to tackle it a step at a time, making sure each step works before you move to the next.


这篇关于如何编写代码控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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