DataGrid select item on user keypress WPF C#

Posted by: jagdeeshk on 30 December 2019, 12:47 am EST

    • Post Options:
    • Link

    Posted 30 December 2019, 12:47 am EST

    Hello,

    I am trying to implement on key press to navigate respective row. suppose when i press letter A, it will navigate to first row where row start with letter A and if user press more than one letter continuously it will navigate to row which start with string.

    private void DataGridViewOfUsersList_KeyDown(object sender, KeyEventArgs e)
            {
                C1.WPF.DataGrid.C1DataGrid dataGrid = sender as C1.WPF.DataGrid.C1DataGrid;
                for (int i = 0; i < (dataGrid.Rows.Count); i++)
                {
                    UsersList usersList = (UsersList)dataGrid[i, 0].Value;
                    string fullName = usersList.user_FullName.ToLower();
                    if (fullName.StartsWith(e.Key.ToString().ToLower(), true, CultureInfo.InvariantCulture))
                    {
                        dataGrid.SelectedIndex = i;
                        dataGrid.ScrollIntoView(1,0);
                        return;
                    }
                }
            }
    

    I implemented like this but it working only for single character. if user press more than one character they are navigating one by one. Is there any way to implement ?

    Thanks,

    Jagdeesh.

  • Posted 30 December 2019, 8:51 pm EST

    Hi Jagdeesh,

    I have replied to the another post that you created for the same request: https://www.grapecity.com/forums/wpf-edition/datagrid-select-item-on-us_1

    Request you to refer the same and please post your further concerns there, if any.

    Best wishes,

    Ruchir

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels