Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2151

Re: Crystal Reports Viewer KeyDown Event

$
0
0

Hi Don,

 

I'm not entirely sure what you're saying in your previous reply. My code tests for the escape key in both the form's as well as the CR Viewer's KeyDown events. So I am testing for a specific key. With the Viewer having Focus, I would have expected the Viewer to handle the KeyDown event, yet it isn't because the Form's KeyDown event is firing instead (as witnessed by the MessageBox text). I don't want to use the Viewer's click event as it is more natural to press the Escape to "get out" or "go back". (Besides, I already have the DoubleClick event set to hide the viewer anyway as a safety net.)

 

I did some more testing by adding a TextBox to the form as this also has a KeyDown event. I added code behind to display a MessageBox advising the Escape was pressed for this control. When the form's KeyPreview property was set True, the Form's KeyDown event would fire first, followed by the TextBox's KeyDown event. When the KeyPreview property was set False, only the TextBox's KeyDown event would fire.

 

Going by this sequence of events, if I set the Form's KeyPreview property to True, the Form's KeyDown event to null and the CR Viewer's KeyDown event to show the MessageBox if the Escape key is pressed, I should see a MessageBox when the CRViewer is visible, has Focus and the Escape key is pressed. Yet, it does not (but id does work for the TextBox).

 

I also experimented by using a different key, the Up Arrow key to be precise, in the KeyUp event. Again, the same response as above was found, i.e. the CR Viewer did not process the KeyDown or KeyUp events.In fact, I found the Up Arrow (and Down Arrow) would move the report page display up/down in the viewer instead. This suggests the Viewer is trapping the keys but not firing the KeyUp/Down events.

 

Now, I'm not a C# expert to say the least, so perhaps I'm missing something here?

 

So whether this is a C# issue, a CR issue or a dumb programmer issue, I'm not sure. Having found a way around it is good as it means I can move on with my project, but I'm not entirely happy because I don't understand what's actually going on and why this is happening.


Viewing all articles
Browse latest Browse all 2151

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>