473,320 Members | 1,948 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,320 software developers and data experts.

Custom DataGrid and overriding ProcessCmdKey

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 myDataGrid.Select(rowNum);

MessageBox.Show is coming up, but this takes no effect on Select or Focus.

Anybody knows why?

Here is the Code:

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
const int WM_KEYDOWN = 0x100;
const int WM_SYSKEYDOWN = 0x104;

int rowIndex = this.CurrentRowIndex;

CManagerMain mainForm = (CManagerMain) this.Parent.FindForm();

if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN))
{
switch(keyData)
{
case Keys.Down:
MessageBox.Show("Box goes up");
this.Select(rowIndex );
break;

case Keys.Up:
MessageBox.Show("Box goes up");
this.Select(rowIndex );
break;

case Keys.Tab:
MessageBox.Show("Box goes up");
mainForm.myTextBox.Focus();
break;
}
}

return base.ProcessCmdKey(ref msg,keyData);
}

Thx in advance :)

Nov 16 '05 #1
2 4275
You are always selecting the current row

int rowIndex = this.CurrentRowIndex
...
// rowIndex is never change
...
this.Select(rowIndex )

Nov 16 '05 #2
Yes, but if I do the same with:

this.Select( 6 );

nothing happens, after I push the button, why?

thx
Susanne

Charlie Williams wrote:
You are always selecting the current row.

int rowIndex = this.CurrentRowIndex;
...
// rowIndex is never changed
...
this.Select(rowIndex );


Nov 16 '05 #3

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

Similar topics

2
by: Nanda | last post by:
Hi all, while editing a datagrid cell, if i press Enter key focus goes to the next row, instead that i would like to have focus on next cell, how can i obtain this. Thanks & Regards, Nanda
1
by: J.H.. | last post by:
With who way I can remove the focus from a DataGrid Control using the key Tab in a WinForm in C# ? The key Tab transports the focus in the next column of DataGrid and no in the next WinForm Control.
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...
3
by: bardo | last post by:
I have a Datagrid that is inside a panel. I want to use the keyDown event to reconize the arrow keys. But I have no luck at all. The problem is that the keydown event won't fire at all, unless I...
1
by: Serdge Kooleman | last post by:
i would like to write my event that will react on specific keys in my custom DataGrid (WinForms)... please help to do this. so far i have this custom grid... and i create it in main object ...
1
by: Diogo Alves - Software Developer | last post by:
I'm tring to override the combination all the combination like this one Ctrl + Shift + . I just can't catch it... I have already done this for ctrl + or Shift + but for both at same timeI can't...
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...
3
by: Melson | last post by:
hi can anyone help me how can i capture ENTER keystroke when the cell in datagrid is in editing mode. I'm now creating a data entry form with primary key in header and details in datagrid. So...
4
by: Melson | last post by:
Hi I've a problem. Can anyone help. I would like to use datagrid for data entry. How can I set the number of rows in the datagrid. And use the datagrid to update the ms sql table. regards...
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.