Solved

Visual Studio 2008 - Key up Event in List Box

Posted on 2011-09-07
4
235 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 500 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

729 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