Home Forums WPF controls Xceed DataGrid for WPF Navigating to a specific cell after adding an item

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

    I am trying to accomplish a specific task with the data grid and having some difficulties. I am hoping you can point me in the right direction.

    I have a method that executes when a user presses SHIFT+Enter while inside the datagrid. I want that method to add an item to the source collection then navigate to the new row, focus a specific cell then begin editting.

    I am able to add the row and set that row to the current item. However, I cannot seem to set the focus to the correct cell and then begin editting.

    Imported from legacy forums. Posted by Jason (had 3458 views)

    Xceed Support
    Member
    Post count: 5658

    To do this, you will have to obtain the container (DataRow) for the CurrentItem.

    To do it:

    DataRow row = dataGridControl.ItemContainerGenerator.ContainerFromItem( dataGridControl.CurrentItem) as DataRow;

    if(row != null)
    {
    Cell cell = row.Cells[ myColumn];
    if(cell != null)
    {
    cell.BeginEdit();
    }
    }

    Note that the DataRow for the data item is created only when the item gets visible… therefore, this process will not work for a row that is out of view… (then you should call BringIntoView() on the item).

    Imported from legacy forums. Posted by Marcus [Xceed] (had 392 views)

    User (Old forums)
    Member
    Post count: 23064

    I tried that method prior to making a post on the forums. Unfortunately, the container for the newly added item returns null.

    Do you know of another approach we can try?

    Imported from legacy forums. Posted by Jason (had 453 views)

    Xceed Support
    Member
    Post count: 5658

    Call dataGridControl.BringIntoView() on the newly added data item… Then you can place a function call on the dispatcher ( Loaded priority ) to do your stuff…

    Imported from legacy forums. Posted by Marcus [Xceed] (had 305 views)

    User (Old forums)
    Member
    Post count: 23064

    Thank you very much for your patience and your help!

    Imported from legacy forums. Posted by Jason (had 4077 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi,

    i have call dataGridControl.BringIntoView()  after add new row to datagrid

    now call

    Xceed.Wpf.DataGrid.

    DataRow row = gvTrnDtlOUT.GetContainerFromItem(gvTrnDtlOUT.CurrentItem) as Xceed.Wpf.DataGrid.DataRow;

    if (row != null)

    {

    Xceed.Wpf.DataGrid.

    Cell cell = row.Cells[0];

    if (cell != null)

    {

    cell.BeginEdit();

    }

    }

    but still focus not set to first column of added grid.

    i dont understand what “Then you can place a function call on the dispatcher ( Loaded priority ) ” this line want to say…

    Sir Please Explain With example i m very new to xceed.

     

    Thanks 

     

    how to

     

    Call dataGridControl.BringIntoView() on the newly added data item… Then you can place a function call on the dispatcher ( Loaded priority ) to do your stuff…

    Imported from legacy forums. Posted by yagnesh (had 1346 views)

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