超震撼dj打碟视频直播:Silverlight ListBox上下移动选项

来源:百度文库 编辑:九乡新闻网 时间:2024/04/29 09:33:37

button1是向上,button2是向下,form2是当前窗体(换成页面也一样)

 

 int upIndex =0; 
private void button1_Click(object sender, EventArgs e)
{
upIndex = this.listBox1.SelectedIndex;
if (upIndex > 0)
{
upIndex--;
}
listBox1.SelectedIndex = upIndex;
}

private void Form2_Load(object sender, EventArgs e)
{
listBox1.SelectedIndex = 0;
}

private void button2_Click(object sender, EventArgs e)
{

upIndex = this.listBox1.SelectedIndex;
if (upIndex < listBox1.Items.Count - 1)
{
upIndex++;
}
listBox1.SelectedIndex = upIndex;
}