Home Forums WPF controls Xceed DataGrid for WPF Delete rows

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

    I have implemented deletion since I didnot see whether or not you implemented that.
    So pls if this is the case add it to the features list.

    Imported from legacy forums. Posted by Itzik (had 5247 views)

    Xceed Support
    Member
    Post count: 5658

    Can you give us an idea of what kind of deletion features you would like to have?

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

    User (Old forums)
    Member
    Post count: 23064

    Wehn a row is selected and I hit delete key I want the row to be removed from the data source and from the presentation grid. as in the old datagridview.

    I have implemented this myself, but found some bugs a long the way:

    I discovered that if I am doing a remove of the grid.CurrentItem from the data source, than the grid.CurrentItem is actually not null and even the selected item sometimes do not get null after deletion even though nothing is selected in the grid.

    By the way in SelectionMode.Extended I cannot select multiple rows by dragging a cliked mouse.

    Here is the code, I solve the bug by clearing selectedItems after deletion.

    /// <summary>
    /// Delete the row
    /// </summary>
    /// <param name=”sender”>The event’s sender</param>
    /// <param name=”e”>The event’s arguments</param>
    void grid_KeyUp(object sender, KeyEventArgs e)
    {
    switch (e.Key)
    {
    case Key.Delete:
    HandleDeleteRows();
    break;
    default:
    break;
    }
    }

    /// <summary>
    /// Handle Delete Rows
    /// </summary>
    private void HandleDeleteRows()
    {
    if (grid.SelectedItems.Count > 0)
    {
    DataView dv = grid.ItemsSource as DataView;
    if (dv != null)
    {
    foreach (DataRowView rv in grid.SelectedItems)
    {
    System.Data.DataRow row = rv.Row;
    _undoStack.Push(row.ItemArray);
    dv.Table.Rows.Remove(row);

    }
    grid.SelectedItems.Clear();
    }
    }
    }

    Imported from legacy forums. Posted by Itzik (had 889 views)

    Xceed Support
    Member
    Post count: 5658

    Great, if you think of any other particular request concerning deletion, do not hesitate to post them here.

    I have noted the problem about CurrentItem and SelectedItems, this will be addressed in an upcoming version.

    Thank you also for the suggestion relating to the multiple selection using the mouse (while dragging), It has been noted and we’ll see what can be done.

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

    User (Old forums)
    Member
    Post count: 23064

    This issue has indeed been resolved in version 1.1, you can obtain the latest version here :

    <a href=”http://download3.xceedsoft.com/Packages/3.0.7264.16200/XceedComponents.exe”>download 1.1 here</a>

    Thank you !

    Imported from legacy forums. Posted by Matt (had 371 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks for offering this solution but it has one problem that I have not found a workaround for.

    When editing a text cell, if you hit the Delete key, it deletes the whole row. Not what the user would expect!

    Imported from legacy forums. Posted by Alan (had 518 views)

    Xceed Support
    Member
    Post count: 5658

    Are you handling the PreviewKeyDown or the KeyDown event?

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

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