473,378 Members | 1,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

ProcessCmdKey question?

Hi!

I need help with calling ProcessCmdKey. I'm little bit confused
how to use this method from my app. How to call it, from where?
Can somebody explain to me?

Thnx.

This is the source:

public class MyDataGrid : DataGrid
{
protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
{
if(msg.WParam.ToInt32() == (int) Keys.Enter)
{
SendKeys.Send("{Tab}");
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}
Nov 11 '08 #1
2 6490
On Tue, 11 Nov 2008 15:12:19 -0800, Trooper <tr*@nema.emailwrote:
Hi!

I need help with calling ProcessCmdKey. I'm little bit confused
how to use this method from my app. How to call it, from where?
Can somebody explain to me?
As the code you posted (you write "this is the source"...the "source" from
where? why is it relevant to your question?) shows, you don't call the
method, you override it. The framework calls it during processing of
window messages, providing the Control instance with an opportunity to
intercept specific messages for special processing.

For example, in your code example, the method is trapping the Enter key
and converting it to a Tab key (presumably to cause the Enter key to move
focus to the next control, just as the Tab key does).

I'm not sure the example you showed is actually the best demonstration of
why one would use it; after all, there are less-invasive ways to catch the
Enter key and use it to move focus. But it does show the basic idea: it's
a way of processing or transforming the raw input at an early stage.

As the MSDN docs state, it would be very unusual for someone to need to
write code that overrides this method. But if you have the need, it's
there for just that purpose.

Pete
Nov 11 '08 #2
Peter Duniho wrote:
On Tue, 11 Nov 2008 15:12:19 -0800, Trooper <tr*@nema.emailwrote:
Thnx a lot. I get it all.
Nov 12 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Susanne Christe | last post by:
Hi Folks, I'm trying to override protected ProcessCmdKey function in writing my a custom MyDataGrid. I get the Keys I want, but it takes no effect to MyDataGrid, if I try for example execute...
0
by: stardv | last post by:
I am trying to override ProcessCmdKey to either bind the data on “Enter” key pressed or return the value of the current cell when enter is pressed on it, whatever would be easier. I have...
1
by: Paul | last post by:
Hi, I am still confused the different between ProcessCmdKey and ProcessDialogKey. When to use it? I write a simple user control and these 2 override functions looks the same to me. ...
0
by: Rachel Suddeth | last post by:
I have been overriding the ProcessCmdKey in my forms because I want to handle some keystrokes that seem to disappear if I try to use the regular key handling events. It seems to be working just...
4
by: jibran | last post by:
Hello. I have wrapped the DataGrid control with my own class (SmartDataGrid) adding some necessary functionality. My current webform has 2 SmartDataGrids. The first is populated by selected...
5
by: Colin Graham | last post by:
I am using the following code on my form to capture whether the tab control has been pressed. Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData...
2
by: Phil Galey | last post by:
I'm using the ProcessCmdKey event to capture various keys that are pressed. However, I'm having trouble capturing the combination of the CTRL key and, say, the DOWN key. If I just press the CTRL...
1
by: John Richardson | last post by:
I'm trying to override the SHIFT-SPACE "negative feature" in the Winforms datagrid, to only be a space. The following link describes this:...
5
by: Peted | last post by:
Hello, i am lookinf for the best way to trap any alphanumeric keypress in all multi key combminations and execute some code For example , i have a form visible using the form.showdialog...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.