Solved

Visual Studio 2008 - Key up Event in List Box

Posted on 2011-09-07
4
214 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
  • 2
  • 2
4 Comments
 
LVL 40

Expert Comment

by:Jacques Bourgeois (James Burger)
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now