Home > Net >  C # form program KeyDown event has occurred is not triggered
C # form program KeyDown event has occurred is not triggered

Time:10-14

My program, first of all, there is a main form and in the Panel established a MDI child forms the child form a Panel and the image of two controls but child form KeyDown event has occurred is not triggered consult why ah (keyPreview is true)

CodePudding user response:

And I found that for the first time to create an MDI child window cut back and cut back to desktop KeyPress may trigger the normal, but close to create a new MDI child window

CodePudding user response:

Did see code, event registration, what place is affected,

CodePudding user response:

Only trigger when the child form a focus

CodePudding user response:

refer to the second floor guwei4037 response:
see code, event to have registered, what place is affected,
look at 1st floor, can sometimes trigger

CodePudding user response:

The
reference 3 floor xuzuning response:
only trigger when the child form a focus
tried to focus it still don't trigger

CodePudding user response:

Problem solve the problem is, indeed, the focus because of the focus has been on the MDI parent form a control, the parent form KeyPreview is set to true after find thank you

CodePudding user response:

refer to 6th floor Liubo5574186 response:
problem solve the problem is, indeed, the focus because of the focus has been on the MDI parent form a control, the parent form KeyPreview is set to true thank you found after

Could you tell me how to solve?

CodePudding user response:

refer to the second floor guwei4037 response:
see code, event to have registered, what place is affected,
not compile time registration will be an error,

CodePudding user response:

Not careless will form into what the Panel control, form "in the" don't put any space, Mdi way is just named Mdi main form, the programming design method of embedding form child controls is wrong,

CodePudding user response:


refer to the original poster Liubo5574186 response:
my program, first of all, there is a main form and in the Panel established a MDI child forms the child form a Panel and the image of two controls but child form the KeyDown event has occurred is not triggered consult why ah (keyPreview is true)
could you tell me how to solve? Recently also encounter this problem
  •  Tags:  
  • C#
  • Related