Custom DataGrid and overriding ProcessCmdKey

  • Thread starter Susanne Christe
  • Start date
S

Susanne Christe

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 :)
 
G

Guest

You are always selecting the current row

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

Susanne Christe

Yes, but if I do the same with:

this.Select( 6 );

nothing happens, after I push the button, why?

thx
Susanne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top