2.3 C#ImageList


ImageList

  • 圖像大小都是一樣,通過屬性ImageSize控制
  • 圖像通過索引或者鍵值來指定

方法

  • Add:添加圖像

  • RemoveAt移除單個圖像,根據索引

  • Clear:清除所有圖像


private void button1_Click(object sender, EventArgs e)
{
    pictureBox1.Width=200;
    pictureBox1.Height = 165;
   
    Image img = Image.FromFile("./294.jpg", true);//創建Imag對象
    imageList1.Images.Add(img);
    imageList1.ImageSize = new Size(200, 165);//設置顯示的大小
    pictureBox1.Image = imageList1.Images[0];
    
}

private void button2_Click(object sender, EventArgs e)
{
    imageList1.Images.RemoveAt(0);
    pictureBox1.Image = null;
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM