Home Forums WinForms controls Xceed Grid for WinForms Insertion row confusion

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

    Just started working with the grid control for the first time. I’m excited, but I don’t understand how to make an Insertion Row do an insert into my bound data object. I just keep typing in it and nothing is ever inserted. Need some help….

    Imported from legacy forums. Posted by Adam (had 1311 views)

    User (Old forums)
    Member
    Post count: 23064

    What type of data object are your referring to?  For example, if you are using a DataSet that is filled from a DataTable in a Database, when inserting rows through the gird, the DataSet will contain the new row, but not the DataTable (this is how the .NET binding mechanism works).  You will need to manually call the update method for the DataTable to be updated with the new row.

    Imported from legacy forums. Posted by André (had 353 views)

    User (Old forums)
    Member
    Post count: 23064

    My problem is more fundamental. When I type something in an insertion row, I’m expecting for a new (blank) row to appear and for the row I entered to be appended to the grid when I tab off the insertion row’s last cell. Instead, focus wraps to the first cell, the row stays in edit mode, and no row is appended. It’s behavior I’ve never seen in a grid control before. (My experience being Microsoft’s built-in DataGridView and Microsoft Access datasheet views.)

     You’re quite right that updating the underlying data source is a separate question. But I don’t care about that right now. All I want to see is a row appended to the grid when I enter one. I’ll worry about saving it later.

    Imported from legacy forums. Posted by Adam (had 681 views)

    User (Old forums)
    Member
    Post count: 23064

    Just to prevent any wild goose chasing–I think the problem here is with my data binding scheme after all–and not the grid.

    That said, I’m still a little baffled by the way inserts work. I would expect that tabbing off the last cell in the insert row would trigger the insert. Instead, tabbing off the last cell just wraps you back to the first cell. I found that the pressing the down arrow causes an insert, which I don’t find intuitive. I’d appreciate a comment/explanation of that behavior.

    Imported from legacy forums. Posted by Adam (had 696 views)

    User (Old forums)
    Member
    Post count: 23064

    You can handle the KeyUp event, and call EndEdit() on the InsertionRow to commit the changes (thus to add the row to the grid).  Note however that you need to add the handler on the first cell, not the last one, because the Tab key is raised on the next cell from the one on which you are when pressing the Tab key.

    e.g.:

    private void Form1_Load(object sender, EventArgs e)

    {

        insertionRow1.Cells[ “First Column” ].KeyUp += new KeyEventHandler( FirstCell_KeyUp );

    }

    void FirstCell_KeyUp( object sender, KeyEventArgs e )

    {

        if( e.KeyCode == Keys.Tab )

        {

            insertionRow1.EndEdit();

        }

    }

    Imported from legacy forums. Posted by André (had 527 views)

    User (Old forums)
    Member
    Post count: 23064

    This can also be done by using the QueryInputKey on the CellEditorManager of the last column.

    e.g.:

    private void Form1_Load(object sender, EventArgs e)

    {

        gridControl1.Columns[ “Last column” ].CellEditorManager.QueryInputKey += new QueryEditorInputKeyEventHandler(CellEditorManager_QueryInputKey);

    }

    void CellEditorManager_QueryInputKey( object sender, QueryEditorInputKeyEventArgs e )

    {

        if( e.Cell.GetType() == typeof( InsertionCell ) )

        {

            if( e.KeyData == Keys.Tab )

            {

                insertionRow1.EndEdit();

            }

        }

    }

    Imported from legacy forums. Posted by André (had 858 views)

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