如何从c#windows应用程序中的文件夹中读取图像 [英] how to read images from folder in c# windows application

查看:165
本文介绍了如何从c#windows应用程序中的文件夹中读取图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从c#windows应用程序中的文件夹中读取图像



朋友们,



我正在工作windows应用程序c#项目。



我的要求是..,

我有两种形式(Form1,Form2)



在form1中它有用户数据输入,带有文本框和下拉列表以及提交按钮。

这里,用户将输入他的数据并将数据存储在Sql表中。



在下拉列表中,它有图像类型可供选择,如快乐,悲伤,正常



无论用户是谁选择form1中的图像...它应该从图像文件夹中读取并显示在form2图片框中。



在表格2中,我有一个图片框控件来显示图像。



请帮助谢谢。

how to read images from folder in c# windows application

Hi friends,

am working of windows application c# project.

my requirement is..,
I have two forms (Form1, Form2)

In form1 it has user data entry with textboxes and dropdownlist and submit button.
here, the user will input his data and data will be stored in Sql table.

In dropdownlist it has images type to select like happy,sad,normal

whatever the user selects image in form1...it should read from images folder and display in form2 picture box.

In form 2, I have a picture box control to display image.

Please help thanks.

推荐答案

如果选项已修复,则不按需加载:从磁盘加载图像 - 使用 Image.FromFile [ ^ ] - 作为主窗体启动的一部分,并将它们存储在Image类实例中。然后,您可以创建第二个表单的Image属性,第一个表单在选择更改时设置。然后该属性设置PictureBox控件以显示实际图像。



如果它们没有修复,则会发生相同的过程,除了文件是在运行时加载的传递给第二个表单实例属性之前的主窗体(并复制到另一个Image实例中以释放文件句柄)。



见这里:在两种表格之间转移信息,第1部分:父母对孩子 [ ^ ]
If the options are fixed, then don't load on demand: load the images from the disk - using Image.FromFile[^] - as part of your main form startup, and store those in Image class instances. You can then create an Image property of your second form which the first sets when the selection changes. The property then sets the PictureBox control to display the actual image.

If they aren't fixed, then the same process occurs, except the file is loaded at runtime by the main form (and copied into a different Image instance to release the file handle) before being passed to the second form instance property.

See here: Transferring information between two forms, Part 1: Parent to Child[^]


这篇关于如何从c#windows应用程序中的文件夹中读取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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