How do you Capture Keyboard shortcuts

  • Thread starter Thread starter Henry
  • Start date Start date
H

Henry

I have a listBox on my form. When the listBox has focus I want to respond
to certain keyboard shortcuts like Ctrl+A that is used to select all
contents as in Word, but I want to apply this to the Items collection of the
listBox.

I am not exactly sure how I can go about this.... I suspect I would add
code to the KeyPress event of the listBox, but that is about as far as I
have gotten so far.

The EventArguments e will have the data, but I don't know what objects I
will need to create, etc.

Can somebody give me guidance?
 
I am trying something like this, but as you will see, I am missing some code
private void lbSelectedScripts_KeyPress(object sender, KeyPressEventArgs e)

{

if (e.KeyChar == Keys.Crsel)//Not sure this is the right key for Ctrl+A

{

foreach (object item in lbSelectedScripts.Items)

{ // need to figure out what to do here to select all items

}



}


}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top