Home Forums WPF controls Xceed DataGrid for WPF seamless input from InsertionRow

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

    Is there a way to enter data in the InsertionRow , tab through the columns, press enter and have the first column ready to receive user input?

    Now after you prees the return key a new InsertionRow is displayed but the first column is not in edit mode.

    Imported from legacy forums. Posted by William (had 1401 views)

    Xceed Support
    Member
    Post count: 5658

    You could derive from InsertionRow and override OnPreviewKeyDown like this:

        protected override void OnPreviewKeyDown( KeyEventArgs e )
        {
          base.OnPreviewKeyDown( e );

          if( e.Key == Key.Enter  )
          {       
            this.Cells[ 0 ].BeginEdit();   
          }
        }

     

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

    User (Old forums)
    Member
    Post count: 23064

    I tried your suggestion and I’m see the same behavior if I did not add the code. I did set a breakpoint and I’m in the code.

    What I’m seeing is when I press the enter button the contents of the insertion row is shifted down into the next row and the insertion row is blank. The far left is showing “>” if I mouse click another cell and then click on the first cell of the insertion row then I’m in edit mode far left showing pencil. What I’m looking for is after I press the return key the first cell is in focus and in insert mode – I can continue typing with changing focus on the cell

     

     

    Imported from legacy forums. Posted by William (had 963 views)

    Xceed Support
    Member
    Post count: 5658

    You should also set the grid’s EditTriggers property to CellIsCurrent | BeginEditCommand | ActivationGesture and the CellEditorDisplayConditions property to CellIsCurrent.

    Sorry about that!

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

    User (Old forums)
    Member
    Post count: 23064

    That worked thanks

    two questions 1 – how do you set the first cell as BeginEdit when the datagrid is initially displayed?

    2 – when I clear my screen I set dataviev binded to the datagrid  to dataview[xxx].Table.Clear(). Besides clearing the entered data it also clears the insertionrow from the gridcontrol. Is there a way to not delete the insertionrow or redisplay it after the clear? 

     

     

    Imported from legacy forums. Posted by William (had 564 views)

    Xceed Support
    Member
    Post count: 5658

    If you are referring to the first cell in the InsertionRow, then you will need to handle its Loaded event, preserve a reference to it and then access its Cells collection to place the first cell in edit mode.

    If you are referring to the first cell in the first datarow, then you will need to use the GetContainerFromItem method to retrieve the Xceed.Wpf.DataGrid.DataRow container and access its Cells collection (in the same manner as the InsertionRow). 

    As for clearing the grid, I suggest that rather than clearing the data view that you set the ItemsSource property to null. You will also need to clear the grid’s collection of columns if the next source you are binding too does not have the same fields/columns.

    [quote]Besides clearing the entered data it also clears the insertionrow from
    the gridcontrol. Is there a way to not delete the insertionrow or
    redisplay it after the clear? [/quote]

    If the column definitions are still present, then the InsertionRow should remain; you may just need to set the Height property to see it. 

     

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

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