很简单问题,请帮帮我!

yangqi0223 2004-11-01 03:00:37
下面有段代码:
这里面我用了imagelist和listview、opendialog、button 4个控件

private void Form1_Load(object sender, System.EventArgs e)
{
//imagelist里面的图片放进listview里面显示出来
imageList1.ImageSize = new Size(100,100);
//image读取图片地址
Image myImage = Image.FromFile(@"图片地址");
imageList1.Images.Add(myImage);
ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem("", 0);
listViewItem1.StateImageIndex = 0;
listView1.Items.AddRange(new System.Windows.Forms.ListViewItem[] {listViewItem1});
listView1.StateImageList = imageList1;
// Sets the first list item to display the 3th image
listView1.Items[0].ImageIndex = 2;
}

private void button1_Click(object sender, System.EventArgs e)
{
//用openfiledialog选择图片的位置
openFileDialog1.Filter = "图像文件 (*.jpg;*.gif)|*.jpg;*.gif|所有文件 (*.*)|*.*" ;
openFileDialog1.Multiselect = true;
if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
StreamReader sr = new StreamReader(openFileDialog1.FileName);

}
}
我现在就想将button 选择的文件放进imagelist里,也就是“图片位置里”这样listview就可以显示出来了
...全文
155 18 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangqi0218 2004-11-03
  • 打赏
  • 举报
回复
1
yangqi0223 2004-11-02
  • 打赏
  • 举报
回复
详细点,谢谢!我是新手
yangqi0223 2004-11-02
  • 打赏
  • 举报
回复
UP
yangqi0223 2004-11-02
  • 打赏
  • 举报
回复
UP
zhgroup 2004-11-01
  • 打赏
  • 举报
回复
将读取图片文件加入Imagelist做成单独的方法,参数为要添加的图片的路径,然后在BUTTON CLICK后,调用此方法,也就是用文件路径建立Image对象。
yangqi0218 2004-11-01
  • 打赏
  • 举报
回复
UP
yangqi0218 2004-11-01
  • 打赏
  • 举报
回复
UP
yangqi0218 2004-11-01
  • 打赏
  • 举报
回复
UP
yangqi0223 2004-11-01
  • 打赏
  • 举报
回复
具体点!谢谢!
wswc3110 2004-11-01
  • 打赏
  • 举报
回复
你用传递文件的路经试试!
yangqi0223 2004-11-01
  • 打赏
  • 举报
回复
没人会?不会吧?
yangqi0223 2004-11-01
  • 打赏
  • 举报
回复
UP
yangqi0223 2004-11-01
  • 打赏
  • 举报
回复
v_object(牵只蚂蚁蹓跶) 你的名字太有个性了!!!
qingping21cn 2004-11-01
  • 打赏
  • 举报
回复
帮你UP
v_object 2004-11-01
  • 打赏
  • 举报
回复
D
yangqi0223 2004-11-01
  • 打赏
  • 举报
回复
HELP!!在线等,急急急!
yangqi0223 2004-11-01
  • 打赏
  • 举报
回复
LG?
520NET 2004-11-01
  • 打赏
  • 举报
回复
LG

111,097

社区成员

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

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

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