欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#實現(xiàn)動態(tài)顯示及動態(tài)移除圖片方法

 更新時間:2014年07月30日 09:07:12   投稿:shichen2014  
這篇文章主要介紹了C#實現(xiàn)動態(tài)顯示及動態(tài)移除圖片方法,對于C#的初學者了解圖像操作有一定的幫助,需要的朋友可以參考下

本文所述實例為C#動態(tài)加載一張圖片并顯示及動態(tài)移除它的實現(xiàn)方法,代碼主要涉及一些C#圖像操作知識,代碼簡單易懂,對C#的初學者有一定的幫助。

主要功能代碼如下:

using System;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ImageListRemovePicture
{
  public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();
    }
    //動態(tài)加載圖片
    private void Form1_Load(object sender, EventArgs e)
    {
      pictureBox1.Width = 200;
      pictureBox1.Height = 165;
      string Path = Application.StartupPath.Substring(0, Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("\\")).LastIndexOf("\\"));
      Path += @"\01.jpg";//加載一張外部圖片
      Image img = Image.FromFile(Path, true);
      imageList1.Images.Add(img);
      imageList1.ImageSize = new Size(200,165);
    }
    private void button1_Click(object sender, EventArgs e)
    {
      if (imageList1.Images.Count == 0)
      {
        MessageBox.Show("沒有圖像可移除!");
      }
      else
      {
        pictureBox1.Image = imageList1.Images[0];
      }
    }
    //動態(tài)移除圖片
    private void button2_Click(object sender, EventArgs e)
    {
      imageList1.Images.RemoveAt(0);
      pictureBox1.Image = null;
    }
  }
}

其他部分如界面及控件的布局,讀者可以根據(jù)自身興趣加以設(shè)計調(diào)整,代碼功能也可根據(jù)自身項目需求進一步的加以完善。

相關(guān)文章

最新評論