Which event is in use
Posted
#1
(In Topic #929)
Enthusiast

1. I scroll the gridview with the mouse wheel and we can see that the rows move.
2. I have a KeyPress Event on the Form1 to detect that you press ESC. But when I scroll, and then press ESC I don't detect the ESC press on the Form1.
Where is the event at that time? Can someone tell me what I can do to find out?
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
Posted
Enthusiast

Can I forward ESC from FMain to Form1 somehow? any other good solution?
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
Posted
Guru

Posted
Guru

(providing they both use Form_Keypress())
In FMain you should be able to do this..
Public methods with an underscore are hidden from other classes in the IDE auto-complete but they can still be used.
Posted
Enthusiast

But I return the focus to Form1 from FMain's KeyPress and then do…
with Desktop.SendKeys in FMain but I don't know how to send ESCAPE, any idea about it. Thanks.
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
Posted
Enthusiast

For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
Posted
Guru

gambafeliz said
It seems that your proposal works.
But I return the focus to Form1 from FMain's KeyPress and then do…
with Desktop.SendKeys in FMain but I don't know how to send ESCAPE, any idea about it. Thanks.
SendKeys should not be needed Because the Key class is valid.
Ie.
in the FMain Form_KeyPress() event if Key.Code = Key.Esc and you call the Fom1.Form_KeyPress() method then Key.Code will be the same as you are still inside the FMain KeyPress event.
gambafeliz said
Hey BruceS your proposal is amazing
cool , glad it works.
Another option is to not let Form1 loose focus.
pressing a button on another form looses the form1 focus so it no longer gets the keypress event , so you could call Form1.SetFocus after any button click on the other form that steals the focus to put it back.
Posted
Enthusiast

I tell you because I press Esc but at that moment I don't know what receives it, let's say the parent and not Form1 as I expected.
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
Posted
Guru

gambafeliz said
But prevent me from stealing the Esc keystroke? give me an example
I tell you because I press Esc but at that moment I don't know what receives it, let's say the parent and not Form1 as I expected.
It's about what has focus.
If you press a button or any other control that is on FMain then that control has the focus and so does FMain.
So a keypress then goes to FMain Keypress event.
If you press a control on Form1 then Form1 has focus.
So if you have a button on FMain called, btnDoSomething it should do this..
Or if you need to monitor the escape key during the function reset the focus first
Maybe you have it working okay, this was just an alternative suggestion.
Posted
Enthusiast

First thank you all for your help. Thanks.
I'll tell you in summary:
The Form1.Form_KeyPress() proposal works but something mysterious is going on that I can't figure out. I tell you but without providing code.
I load data into a GridView and when I click on a row it reloads this GridView with another query. And when I hit ESC I go back to the previous query and load it into the same GridView. Since I remember these queries, I load them into a String array and remove or add queries based on Click or Esc.
The problem is that when I use Form1.Form_KeyPress() in FMain, it works but when it repeats the KeyPress() code in Form1, although I follow it and see that it does everything right, the GridView freezes with the data it had, and it doesn't I don't know where I don't know what happens with the data I upload.
My solution: When Esc is lost and stolen by FMain instead of using Form1.Form_KeyPress(), I use Form1.SetFocus() but this has another problem and that is that the user's Esc key is lost, and I have no choice but to to make the user think that he did not press well and when he repeats Esc then everything is fine, but this for me is a rookie mistake.
What is your opinion? Thanks.
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
1 guest and 0 members have just viewed this.



