• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

Visual Studio 2008 - Key up Event in List Box

Private Sub LBoxSavedReports_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles LBoxSavedReports.KeyUp

I have the above key up event for a Listbox.  It appears to ignore the event.  I placed a stop in the code but it does not stop nor does the code run.  It appears to ignore the code.  I'm not clear what has caused the code to be ignored.
0
dastaub
Asked:
dastaub
  • 2
  • 2
1 Solution
 
Jacques Bourgeois (James Burger)Commented:
I do not have VS2008 available anymore, there might be a bug that I missed while working in that version (such as the DoubleClick that never fired on a ComboBox in VS2002). In VS2010, it works not matter the key.

A few ideas.

Is this for any key, or for a given key?

Is the ListBox Enabled property set to True?

This one is obvious, but sometimes we do those strange mistakes when debugging. Is the cursor in the ListBox when you release the key?

Sometimes, changing the value of a property has indirect impact somewhere. The properties that are in bold in the Properties window are those that are not set to their default. One by one, reset them to the default with a Right click on the property name (some properties cannot be reset, but those should not be the cause of your problem). You might find one that has an indirect impact on the KeyUp.

If you do not find the cause of the problem, tell us what you want to do on the KeyUp. There might be an alternative.



0
 
dastaubAuthor Commented:
Tell us what you want to do on the KeyUp. There might be an alternative.

i use the "DEL" key to delete the highlighted row in the listbox  The right-click is already used.
0
 
Jacques Bourgeois (James Burger)Commented:
Strange, Del is catched, I have just checked. So there is definitively something wrong in the application, such as a stray property interaction somewhere.

Does KeyDown receives the key?

If yes, then there is something in between the 2 events that grabs the key. Stop in KeyDown and trace the code with F11 (or Shift-F8, depending on how you configured your environment).

Or trap Del at the form level. In order to do so, you must first set the KeyPreview property of the form to True. This will send the key to the form KeyUp event before sending it to any control. Once again you might try to trace from there to see what could prevent the key from going out to the ListBox.

If not, here are a few alternatives.

Maybe a small button beside the listbox? Does not have to be big or have Delete ou D├ętruire on it, a simple X or trash can icon is usually sufficient for the user to understant its use.

Or, trap Del at the form level, and have code such as the following:
If ListBox1.Focused Then
   'Do your stuff
End If

Open in new window

0
 
dastaubAuthor Commented:
it turned out to be the listbox was losing focus due to other code in the project.  I was able to find this by using your suggestion of a keypreview for the form.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now