Home Forums WinForms controls Xceed Grid for WinForms Inserting a row using the Insert row causes frustration for the user.

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

    When someone inserts a row using the insert line and they press
    the Enter key in the first cell the row is added and moves to the bottom
    of the Grid (if no sorting).  The user then needs to find the row they just added and
    finish adding data to the rest of the cells.

    Is there a way to prevent this or at least move the focus to the newly add row?

    Imported from legacy forums. Posted by Morgan (had 2914 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Morgan,

    To move the focus onto the newly added row, you should set it as current via the CurrentRow property.

    For example:

    this.grid.DataRows[ this. grid.DataRows.Count – 1 ].CanBeCurrent = true;

                this. grid.CurrentRow = this. grid.DataRows[ this. grid.DataRows.Count – 1 ];

    Imported from legacy forums. Posted by Mohamed [Xceed] (had 227 views)

    User (Old forums)
    Member
    Post count: 23064

    Where should I place this code so that is run when the user presses Enter in a cell on the Insert Bar?

    I found that if I declare withevents then the event is available and it works  (Private WithEvents m_insertionRow As Xceed.Grid.InsertionRow)

    But how can I also set the cell to the one the user was entering into?  I tried the following but it puts me back to the insert row.

       Private Sub m_insertionRow_EditEnded(ByVal sender As Object, ByVal e As System.EventArgs) Handles m_insertionRow.EditEnded
          GridControl1.DataRows(GridControl1.DataRows.Count – 1).CanBeCurrent = True
          Dim cCell As Cell = GridControl1.CurrentCell
          GridControl1.CurrentRow = GridControl1.DataRows(GridControl1.DataRows.Count – 1)
          GridControl1.CurrentCell = cCell
       End Sub

    I have also tried the following but the CurrentCell always seems to be the first cell in the grid.

          Dim ss As String = GridControl1.CurrentCell.AccessibleName
          GridControl1.CurrentRow = GridControl1.DataRows(GridControl1.DataRows.Count – 1)
          GridControl1.CurrentCell = GridControl1.DataRows(GridControl1.DataRows.Count – 1).Cells(ss)
     

     

     

    Imported from legacy forums. Posted by Morgan (had 380 views)

    User (Old forums)
    Member
    Post count: 23064

    I found the solution. It may not be the best but it works.

    Declare a module level variable to capture the AccessibleName of the column being edited:

    Private mInsertColName As String = “”

       Private Sub m_insertionRow_EndingEdit(ByVal sender As Object, ByVal e
    As System.ComponentModel.CancelEventArgs) Handles
    m_insertionRow.EndingEdit
          mInsertColName = GridControl1.CurrentCell.AccessibleName
       End Sub 

       Private Sub m_insertionRow_EditEnded(ByVal sender As Object, ByVal e As System.EventArgs) Handles m_insertionRow.EditEnded
          GridControl1.CurrentRow = GridControl1.DataRows(GridControl1.DataRows.Count – 1)
          GridControl1.CurrentCell = GridControl1.DataRows(GridControl1.DataRows.Count – 1).Cells(mInsertColName)
       End Sub

    Imported from legacy forums. Posted by Morgan (had 917 views)

    User (Old forums)
    Member
    Post count: 23064

    To move the focus onto the newly added row, you should set it as current via the CurrentRow property.

    Hi xceed group

     i have added dynamically a data row by clicking add newitem buttom . but the focus is not moving to the newly inserted row. its remain in the first row of datagrid.i want the focus should move to first column of inserted row and it should be editable. can any one help me out

    Imported from legacy forums. Posted by devanathan (had 1288 views)

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