日期:2014-05-18  浏览次数:20838 次

ImageList问题
我程序:
System.Windows.Forms.ImageList imagelist = new ImageList();  
  DirectoryInfo finfo = new DirectoryInfo(System.IO.Path.GetFullPath("../../img"));
  FileSystemInfo[] f = finfo.GetFileSystemInfos();
  for (int i = 0; i < f.Length ; i++)
  {  
  string mj=f[i].ToString();
  imagelist.Images.Add(Image.FromFile(System.IO.Path.GetFullPath("../../img/") + mj));  
  }  
我全都导入到ImageList后,但是我图片大小,长宽不一样,当我用:
this.picbox.Image=imagelist.Images[0];
this.picbox1.Image=imagelist.Images[1];
的时候,宽度和长度成了imagelist的默认值,我想问下,怎么才能让他改变长与宽???

------解决方案--------------------
可以用重绘:

private void button1_Click(object sender, EventArgs e)
{
Graphics grh = pictureBox1.CreateGraphics(); 
Pen p = new Pen(Color.Blue);
grh.DrawImage(imageList1.Images[0], 10, 20, 100, 100);//100,100为宽和高,10,20为坐标

}