I would like to chang the values of list by the up and down arrow keys of keyboard,
how to make it. nowi am using some lines under 'keydown' event of list box
listBox1.Focus();
listBox1.Select();
listBox1.Visible = true;
if (e.KeyCode == Keys.Up)
{
this.listBox1.SelectedIndex--;
}
else if (e.KeyCode == Keys.Down)
{
this.listBox1.SelectedIndex++;
}
}
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Saber ShaikhPosted Feb 7, 2015, 1:44 AM
{
listBox1.Focus(); listBox1.Select();
listBox1.Visible = true;
if (e.KeyCode == Keys.Up)
{
this.listBox1.SelectedIndex=-1;
this.label1.Text = listBox1.SelectedIndex.ToString();
}
}
private void listBox1_KeyDown(object sender, KeyEventArgs e)
{
listBox1.Focus(); listBox1.Select();
listBox1.Visible = true;
if (e.KeyCode == Keys.Down)
{
this.listBox1.SelectedIndex=+1;
this.label1.Text = listBox1.SelectedIndex.ToString();
}
}
Blog: http://aspnettutorialscode.blogspot.in/