我要实现用DataGridView显示用户从OpenFileDialogue选中的图片缩略图和图片名称

yongchaochu 2010-04-30 06:00:13
DataGridView具体列如下
【图片缩略图】【图片名称】【删除按钮】
以下是代码
OpenFileDialog openFileDialogue = new OpenFileDialog();

openFileDialogue.Filter = "JPG(*.jpg)|*.jpg|GIF(*.gif)|*.gif|PNG(*.png)|*.png|BMP(*.bmp)|*.bmp";
openFileDialogue.FilterIndex = 1;
openFileDialogue.RestoreDirectory = true;
openFileDialogue.Multiselect = true;

if (openFileDialogue.ShowDialog() == DialogResult.OK)
{

foreach (string s in openFileDialogue.FileNames)
{
string filename=Path.GetFileName(s);
MessageBox.Show(filename);
//下面用DataGridView绑定数据
//上面的代码没问题 就是不知道这块怎么绑定了

}
...全文
279 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
yueqinhuang1983 2010-12-03
  • 打赏
  • 举报
回复
cad图形什么传呢?
yongchaochu 2010-05-05
  • 打赏
  • 举报
回复
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "*.jpg;*.bmp;*.gif;*.jpeg|*.jpg;*.bmp;*.gif;*.jpeg";
dialog.Multiselect = true;
if (dialog.ShowDialog() == DialogResult.OK)
{
foreach (string fileName in dialog.FileNames)
{
int index = this.dataGridView.Rows.Add();
DataGridViewRow row = this.dataGridView.Rows[index];
((DataGridViewImageCell)row.Cells["cImage"]).ImageLayout = DataGridViewImageCellLayout.Zoom;
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
Image img = Image.FromStream(fs);
((DataGridViewImageCell)row.Cells["cImage"]).Value = img;
((DataGridViewTextBoxCell)row.Cells["cImageLocation"]).Value = fileName;
((DataGridViewTextBoxCell)row.Cells["cHref"]).Value = "";
((DataGridViewTextBoxCell)row.Cells["cStatus"]).Value = "未上传";
((DataGridViewButtonCell)row.Cells["cDelete"]).Value = "删除";
fs.Close();
}
}
yufenghua 2010-04-30
  • 打赏
  • 举报
回复
如梦兄都发话了 我就只能帮顶了。。。呵呵
wuyq11 2010-04-30
  • 打赏
  • 举报
回复
使用DataGridViewImageColumn
DataGridViewImageColumn column = new DataGridViewImageColumn();
dataGridView1.Columns.Add(column);
column.HeaderText = "图片";
column.Image = System.Drawing.Image.FromFile("路径");
((DataGridViewImageCell)this.dataGridView1.Rows[e.RowIndex].Cells[ "图片列"]).Value = "路经 "

private void dataGridview1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (dataGridview1.Columns[e.ColumnIndex].Name.Equals("Image"))
{
string path = e.Value.ToString();
e.Value = GetImage(path);
}
}
public System.Drawing.Image GetImage(string path)
{
System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Open);
System.Drawing.Image result = System.Drawing.Image.FromStream(fs);
fs.Close();
return result;
}
数据名称:337个城市智慧健康养老DID数据(2017-2025) 数据范围:31省 数据来源:工信部 数据注意:智慧健康养老是以智能硬件、数字化服务平台为载体,融合物联网、大数据、云计算、AI 等信息技术,围绕老年人健康管护、日常养老两大需求形成的新型产业与服务体系;核心是把健康管理、安全监护、生活照料、医疗康复、精神慰藉打通,实现医养结合、居家 - 社区 - 机构一体化,缓解老龄化与护理人力缺口压力 数据指标:city、year、treat Python 数据分析完整实操流程 整体分为 6 大步骤:数据读取 → 数据清洗(最耗时)→ 描述性统计探索 → 可视化分析 → 深度挖掘(相关性、分组、回归等)→ 结果导出 常用工具库: 数据读写、表格处理:pandas 数值计算:numpy 绘图可视化:matplotlib、seaborn 高级统计 / 机器学习:scipy、scikit-learn 我国智慧健康养老产业持续深化落地,各地依托数字技术、智能终端、大数据平台,逐步构建起机构、社区、居家三位一体的智慧养老服务体系,数字化赋能养老服务转型升级成效持续显现。 全国多地持续推进智慧养老院建设、居家养老智能设备布设、养老服务数字化平台搭建,逐步实现养老服务精准化、监管智能化、供给多元化。 各地积极探索养老数据资源化利用、医养智慧融合、适老科技产品落地应用,形成了一批可复制、可推广的城市智慧养老发展模式。

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧