Home Forums WPF controls Xceed DataGrid for WPF Move the focus to the next editable row

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #24274 |

    Hello,

    I have a datagrid, with only one row editable.
    well, when I press Enter, I would to move the focus to the next edirow

    | read only | read only | EDITABLE 1 |readonly|
    | read only | read only | EDITABLE 2 |readonly|
    | read only | read only | EDITABLE 3 |readonly|

    I woul like to pass from EDITABLE 1 to 2 when I press Enter in EDITABLE 1.. etc.

    It is possible?

    Imported from legacy forums. Posted by serhio (had 3430 views)

    Xceed Support
    Member
    Post count: 5658

    You could try something like this in the grid’s KeyDown event:

    <code>
    private void EnterKeyDown( object sender, KeyEventArgs e )
    {
    if( ( e.Key == Key.Enter ) || ( e.Key == Key.Tab ) )
    {
    int index = this.OrdersGrid.CurrentColumn.VisiblePosition;

    Xceed.Wpf.DataGrid.DataRow currentRow = this.OrdersGrid.GetContainerFromItem( this.OrdersGrid.CurrentItem ) as Xceed.Wpf.DataGrid.DataRow;

    int currentIndex = this.OrdersGrid.Items.IndexOf( this.OrdersGrid.CurrentItem );
    this.OrdersGrid.CurrentColumn = this.OrdersGrid.Columns[ “ShipCountry” ];
    this.OrdersGrid.CurrentItem = this.OrdersGrid.Items[ currentIndex + 1 ];
    e.Handled = true;
    }
    }
    </code>

    Where “ShipCountry” represents the name of the column that is editable.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 1374 views)

    User (Old forums)
    Member
    Post count: 23064

    hm.

    ‘Xceed.Wpf.DataGrid.DataGridControl’ does not contain a definition for ‘GetContainerFromItem’

    for
    ‘Xceed.Wpf.DataGrid.DataGridControl’
    v1.0.7113.3050

    Imported from legacy forums. Posted by serhio (had 506 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks 4 your help, Jenny!

    Xceed.Wpf.DataGrid.DataRow currentRow = this.dgcMainDataGrid.ItemContainerGenerator.ContainerFromItem(this.dgcMainDataGrid.CurrentItem) as Xceed.Wpf.DataGrid.DataRow;

    works for my version! 😉

    Imported from legacy forums. Posted by serhio (had 588 views)

    Xceed Support
    Member
    Post count: 5658

    Note that ItemContainerGenerator has been made obsolete as of version 1.1 and GetContainerFromItem should be used instead.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 9242 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.