码迷,mamicode.com
首页 > 其他好文 > 详细

Chapter 5. ListBox控件(双击播放图片)

时间:2016-07-05 01:06:44      阅读:237      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace ListBox控件
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < path.Length; i++)
            {
                string fileName = Path.GetFileName(path[i]);
                listBox1.Items.Add(fileName);
            }
        }

        string[] path = Directory.GetFiles(@"C:\Users\Administrator\Desktop\新建文件夹");

        //双击播放图片
        private void listBox1_DoubleClick(object sender, EventArgs e)
        {
            pictureBox1.Image = Image.FromFile(path[listBox1.SelectedIndex]);
        }
    }
}

技术分享

技术分享

技术分享

 

Chapter 5. ListBox控件(双击播放图片)

标签:

原文地址:http://www.cnblogs.com/xiao55/p/5642042.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!