This is a migrated thread and some comments may be shown as answers.

Cleaar the cell content at runtime

2 Answers 43 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Marius
Top achievements
Rank 1
Marius asked on 17 Dec 2010, 10:47 AM
I'm changing the default behaviour of the RadGridView so that pressing delete does not delete the row but instead clears the selected cells content (excel style behaviour), i've also remapped delete to shift+delete. Everything is working fine, except for the fact that i can't seem to be able to clear the current cell programmatically. Here is the code in my custom command (simple 1.st ver):

        private void ClearCurrentCell(object obj)
        {
            if (_grid.CurrentCell == null)
                return;

            bool wasInEditMode = _grid.CurrentCell.IsInEditMode;

            if (!wasInEditMode)
                _grid.CurrentCell.BeginEdit();

            _grid.CurrentCell.Value = null;

            if (!wasInEditMode && _grid.CurrentCell.IsValid)
                _grid.CurrentCell.CommitEdit();
        }

But the cell revers to the bound value upon commit. How can I achieve this effect? Remember that I don't know the type of datasource bound to the cell.

2 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 20 Dec 2010, 11:39 AM
Hi Marius,

You may try to set the Content property of CurrentCell to null, instead of the Value property, to achieve deletion of the displayed value.  But please, bear in mind that if you put this cell in edit mode after the deletion, the content will be recreated and the bound value will be reset.

Regards,
Ivan X1
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Marius
Top achievements
Rank 1
answered on 20 Dec 2010, 11:46 AM
I want to push the change to the datasource, not only clear the displayed value.
Tags
GridView
Asked by
Marius
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Marius
Top achievements
Rank 1
Share this question
or