Datagrid cell focus

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nanda

    #1

    Datagrid cell focus

    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
  • SurfCoder

    #2
    Re: Datagrid cell focus

    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(r ef
    System.Windows. Forms.Message msg, System.Windows. Forms.Keys keyData)

    {

    if(msg.WParam.T oInt32() == (int) Keys.Enter)

    {

    SendKeys.Send(" {Tab}");

    return true;

    }

    return base.ProcessCmd Key(ref msg, keyData);

    }

    }





    [VB.NET]

    Public Class MyDataGrid

    Inherits DataGrid



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

    If msg.WParam.ToIn t32() = CInt(Keys.Enter ) Then

    SendKeys.Send(" {Tab}")

    Return True

    End If

    Return MyBase.ProcessC mdKey(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" <csenanda@hotma il.com> wrote in message
    news:0b6c01c357 46$8da342c0$a30 1280a@phx.gbl.. .[color=blue]
    > 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[/color]


    Comment

    • Nanda

      #3
      Re: Datagrid cell focus

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

      Regds,
      Nanda.[color=blue]
      >-----Original Message-----
      >Hey Nanda
      >
      >this could help!!!!
      > You can override ProcessCmdKey, catch the Enter[/color]
      Key, and swap it for a[color=blue]
      >Tab key by sending a Tab, and not processing the Enter[/color]
      Key.[color=blue]
      >
      > [C#]
      >
      > public class MyDataGrid : DataGrid
      >
      > {
      >
      > protected override bool ProcessCmdKey(r ef
      >System.Windows .Forms.Message msg,[/color]
      System.Windows. Forms.Keys keyData)[color=blue]
      >
      > {
      >
      > if(msg.WParam.T oInt32() == (int)[/color]
      Keys.Enter)[color=blue]
      >
      > {
      >
      > SendKeys.Send(" {Tab}");
      >
      > return true;
      >
      > }
      >
      > return base.ProcessCmd Key(ref msg,[/color]
      keyData);[color=blue]
      >
      > }
      >
      > }
      >
      >
      >
      >
      >
      > [VB.NET]
      >
      > Public Class MyDataGrid
      >
      > Inherits DataGrid
      >
      >
      >
      > Protected Overrides Function ProcessCmdKey[/color]
      (ByRef msg As[color=blue]
      >System.Windows .Forms.Message, keyData As[/color]
      System.Windows. Forms.Keys) As[color=blue]
      >Boolean
      >
      > If msg.WParam.ToIn t32() = CInt[/color]
      (Keys.Enter) Then[color=blue]
      >
      > SendKeys.Send(" {Tab}")
      >
      > Return True
      >
      > End If
      >
      > Return MyBase.ProcessC mdKey(msg,[/color]
      keyData)[color=blue]
      >
      > End Function 'ProcessCmdKey
      >
      >
      >
      > End Class 'MyDataGrid
      >
      >
      >
      >found on best Faq site!!!!
      >
      >http://www.syncfusion.com/FAQ/WinForms/default.asp
      >
      >
      >Kind regards
      >
      > SurfCoder
      >
      >"Nanda" <csenanda@hotma il.com> wrote in message
      >news:0b6c01c35 746$8da342c0$a3 01280a@phx.gbl. ..[color=green]
      >> 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[/color]
      >
      >
      >.
      >[/color]

      Comment

      Working...