//将获得歌曲数据填充到listMusic1中,然后执行下面的代码
private void MainForm_Load(object sender, EventArgs e)
{
this.listMusic1.Items.Clear();
foreach (DataRow dr in ds.Tables[0].Rows)
{
string str = dr[ "MusicID "].ToString() + " " + dr[ "音乐"].ToString() + " " + dr[ "歌星"].ToString();
this.listBox1.Items.Add(str);
}
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
this.textBox1.Text = this.listMusic1.Text;
} |