?
Solved

Visual Studio 2008 - Key up Event in List Box

Posted on 2011-09-07
4
Medium Priority
?
252 Views
Last Modified: 2012-05-12
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
Comment
Question by:dastaub
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 40
ID: 36500418
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
 

Author Comment

by:dastaub
ID: 36500779
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
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 2000 total points
ID: 36503923
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
 

Author Comment

by:dastaub
ID: 36508347
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question