473,387 Members | 1,583 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,387 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 4284
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.