Walking around the C#.Net 2015 may be little bit fun. Today I will introduce keystroke and show how it can help to move focus between controls.
Sendkeys Object in .Net frame work help you to fire some key stroke, which will enable functions such as move focus forward and backward with the send() method.
Sendkeys Object in .Net frame work help you to fire some key stroke, which will enable functions such as move focus forward and backward with the send() method.
Lets’ start with building a Key Press event for the following Pcode Textbox.
Making of the Key Press Event
Go to the Property Box – Choose Event – locate Key Press and enter Key Press event name as “EnterKey_Treatment” and hit enter, will bring the method structure code.
Now select all controls with Ctrl + Click and select Key Press Event as EnterKey_Treatment. You can also do it individually. This would save our time indeed.
Applying Keystroke
For proper working of the keystroke for moving from one box to another, you have keep the Tab Index of all boxes in as sequential order, i.e, 0,1,2 and so on.Let’s fill this cup with some hot tea.
But the MoveToMox and common static class not yet defined, we need the fuel from the common class.( A static class act like a library, it can be called anywhere in the project).
Static class for Keystroke (MoveToBox)
A static class can contain only static members, and it can access without creating the object, it act like C# library for our project.
For utilizing the KeyPressEventArgs(accessing the keys the user press), have to reference System.Windows.Forms. The new class would look like,
For utilizing the KeyPressEventArgs(accessing the keys the user press), have to reference System.Windows.Forms. The new class would look like,