Enter Key ignored...REALLY weird bug

  • Thread starter Thread starter ZorpiedoMan
  • Start date Start date
Z

ZorpiedoMan

This is so weird, and I cannot even isolate the cause enough to give any
clues as to how to reproduce the error, so this is probably a real shot
in the dark...

BUT, has anyone ever run into a situation where pressing the enter key
on a textbox control is NOT captured by the KeyPress event?

Now before you ask:

-- The form does NOT have a default button selected.
-- The form does have key preview set to true, but setting it to false
has no effect on this problem.


--Zorpie
 
Hi Zorpie

I'm guessing that if you can cut your project down to the minimum set where
this problem still occurs, and you post it here, someone will be able to
spot the problem pretty quickly.

Charles
 
Hi Zorpie,

I'm having similar problems. It's really strange: I have a picturebox
control and all KeyDown events are nicely catched by the forms KeyDown
routine. Only four keys are not catched: the four arrow keys...

How did you solve your enter key problem...???

Thanks, Rud.
 
Rud -

Well, I never ended up finding the cause of my problem and found another
work around.

Your problem, however, is this: The arrow kesy (as well as pgUp, pgDn,
Home, End and a handful of others) is NOT captured by the keypress
event. You need to use the KeyDown or KeyUp event to catch these...

Good Luck.

--Zorpie
 
Thanks Zorpie,

I am using the KeyDown event and not KeyPress (see my mail)! The problem is
as followes: I have an MDI form with two child forms. No matter what I do to
trap the arrow key in the child form, pressing the arrow keys result in:
1) Focus is switched to the next (or previous) open MDI child window, and
2) The KeyDown event is not captured by the child forms KeyDown routine...
For sure "KeyPreview = true" is set for the child form.

I have solved issue 2) - such that I am trapping the arrow key event - as
follows:

Protected Overrides Function ProcessCmdKey(ByRef msg As
System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As
Boolean
MsgBox(keyData)
MyBase.ProcessCmdKey(msg, keyData)
End Function

But I can not manage to stop the unwanted behaviour that pressing the arrow
keys also results in switching the focus from one MDI child form to the
other....

Thanks,

Rud.
 
oops, sorry for the dumb answer. I never went back and read your
comment... I was tired.

anyway, I can't even duplicate your problem. is the picture box the
ONLY control on the child forms?



--Zorpie
 
It was, I temporarely solved the whole problem by placing a "dummy" TextBox
on the form as well. I positioned it outside the form (0,-40) such that it
is invisible for the user. Disabeling did not solve the problem. So for some
reason as long as there is a control (textbox, or commandbutton) that has or
can have the focus all key events are raised. As soon as the picturbox is
the only control again the strange behaviour occurs...

Rud.
 
Rud -

You know, now that you describe your situation and your work around, I
remember years ago making that SAME discovery, even in VB6. I forget if
I ever found out why it behaves that way though. Anyway, good luck!
Looks like you are back on track now.

--Zorpie
 
Please try the KeyDown event, which can return the Key presed value.

Note
There is also the AcceptsReturn property of the text box, which is False
by default.

with regards,


J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com
 
Zorpiedo Man,

Calling somethig a "bug" needs a good documented explanation of what
something should do confirm the documentation and a sample to reproduce the
bug.

When you can not produce that, you can call it only a bug in your programma
and than you should write that in the subject of this message in my opinion.

Now you give me the idea that you only want to blamme the programmers from
Microsoft with your own incapacity.

Not saying that it is as I wrote above, however in the way you do this
giving me strongly the idea.

And than it is not nice in my opinion.

Cor

"ZorpiedoMan"
...
 
Back
Top