Guys I just want to ask why my KeyPress event is apparently not working. What I want is that when I press the letter m, the selectedindex property of my listboxes would change.
Here is the code;
Select Case Asc(e.KeyChar)
Case 13
Try
tray.ListBox1.SelectedIndex = tray.ListBox1.SelectedIndex + 1
tray.ListBox2.SelectedIndex = tray.ListBox1.SelectedIndex
PictureBox1.ImageLocation = tray.ListBox2.SelectedItem
e.Handled = True
Catch ex As Exception
ToolStripLabel1.Text = ex.Message
End Try
Case 26
Try
tray.ListBox1.SelectedIndex = tray.ListBox1.SelectedIndex - 1
tray.ListBox2.SelectedIndex = tray.ListBox1.SelectedIndex
PictureBox1.ImageLocation = tray.ListBox2.SelectedItem
e.Handled = True
Catch ex As Exception
ToolStripLabel1.Text = ex.Message
End Try
End Select
I also want to know what the "e.handled = true" is statement for. I set the KeyPreview property of my form to false and true but it's not working as well.
the KeyPress event should be triggered regardless of the control within the form that is in focus.
Thanks