如何在listbox中双击实现事件
我在用vs2010写一个mp3的播放器,想在listbox中的歌曲列表实现双击播放,请问怎么实现??
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void 添加ToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog of = new OpenFileDialog();
of.Multiselect = true;
of.Filter = "音频文件(*.wav;*.snd;*.au;*.aif;*.aifc;*.aiff;*.wma;*.mp3)|*.wav;*.snd;*.au;*.aif;*.aifc;*.aiff;*.wma;*.mp3";
if (of.ShowDialog() == DialogResult.OK)
{
foreach (string filename in of.FileNames)
this.axWindowsMediaPlayer1.currentPlaylist.insertItem(
this.axWindowsMediaPlayer1.currentPlaylist.count,
this.axWindowsMediaPlayer1.newMedia(filename));
listBox1.Items.AddRange(of.SafeFileNames);
}
}
private void 全部移除ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (listBox1.Items.Count > 0)
{
axWindowsMediaPlayer1.Ctlcontrols.stop();
listBox1.Items.Clear();
axWindowsMediaPlayer1.currentPlaylist.clear();
}
}
private void 单项移除ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (listBox1.Items.Count > 0)
{
int index = listBox1.SelectedIndex;
axWindowsMediaPlayer1.currentPlaylist.removeItem(
axWindowsMediaPlayer1.currentPlaylist.get_Item(index));
listBox1.Items.RemoveAt(index);
}
}
private void ListBox1_DoubleClick(object sender, EventArgs e)
{
}
这是代码