Datagrid cell focus

  • Thread starter Thread starter Nanda
  • Start date Start date
N

Nanda

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
 
Hey Nanda

this could help!!!!
You can override ProcessCmdKey, catch the Enter Key, and swap it for a
Tab key by sending a Tab, and not processing the Enter Key.

[C#]

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);

}

}





[VB.NET]

Public Class MyDataGrid

Inherits DataGrid



Protected Overrides Function ProcessCmdKey(ByRef msg As
System.Windows.Forms.Message, keyData As System.Windows.Forms.Keys) As
Boolean

If msg.WParam.ToInt32() = CInt(Keys.Enter) Then

SendKeys.Send("{Tab}")

Return True

End If

Return MyBase.ProcessCmdKey(msg, keyData)

End Function 'ProcessCmdKey



End Class 'MyDataGrid



found on best Faq site!!!!

http://www.syncfusion.com/FAQ/WinForms/default.asp


Kind regards

SurfCoder
 
Hi,
Thanx for your reply. I hope it would help me.

Regds,
Nanda.
-----Original Message-----
Hey Nanda

this could help!!!!
You can override ProcessCmdKey, catch the Enter Key, and swap it for a
Tab key by sending a Tab, and not processing the Enter Key.

[C#]

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);

}

}





[VB.NET]

Public Class MyDataGrid

Inherits DataGrid



Protected Overrides Function ProcessCmdKey (ByRef msg As
System.Windows.Forms.Message, keyData As System.Windows.Forms.Keys) As
Boolean

If msg.WParam.ToInt32() = CInt (Keys.Enter) Then

SendKeys.Send("{Tab}")

Return True

End If

Return MyBase.ProcessCmdKey(msg, keyData)

End Function 'ProcessCmdKey



End Class 'MyDataGrid



found on best Faq site!!!!

http://www.syncfusion.com/FAQ/WinForms/default.asp


Kind regards

SurfCoder

Nanda said:
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


.
 
Back
Top