代码改变世界

DataGridView插入图片

2010-01-23 22:15  calm_水手  阅读(1001)  评论(1编辑  收藏  举报
  private void Form1_Load(object sender, EventArgs e)
        {
//直接赋值
           //dataGridView1[0, 0].Value = Image.FromFile("E:\\文件\\最美的地方\\1.jpg/");
           //dataGridView1[0, 0].Value = this.imageList1.Images[2];
 //通过imagelist作为中介然后赋值         
           for (int i = 0; i < imageList1.Images.Count; i++)
           {
               dataGridView1.Rows.Add();
               dataGridView1[i, 0].Value = this.imageList1.Images[i];
           }
               
        }
//通过事件绘制
        //private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        //{
        //    e.Value = imageList1.Images[0];
        //}
    }