Home Forums WPF controls Xceed DataGrid for WPF How to Disable (Row) Editing based on some value in the row

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

    Hi,
    I have a grid where i should not allow editing if the first column in the row as certain values if not then i should allow editing. How can i achieve this in xceed wpf datagrid.

    Imported from legacy forums. Posted by sethu (had 749 views)

    Xceed Support
    Member
    Post count: 5658

    You can derive from Row (or DataRow) and override the BeginEdit method to do the required field validation before a row is edited.

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

    User (Old forums)
    Member
    Post count: 23064

    I am new to this control, Is there any example showing how to do ?
    I have the following questions.

    1) i looked at BeginEdit and it returns void ? ( how do i stop the edit in begin edit )
    2) how do i set the newly created DataRow derived object to the grid

    thank you

    Imported from legacy forums. Posted by sethu (had 570 views)

    Xceed Support
    Member
    Post count: 5658

    Please refer to the following post:

    <a href=”http://forums.xceed.com/forums/ShowPost.aspx?PostID=9382″>http://forums.xceed.com/forums/ShowPost.aspx?PostID=9382</a&gt;

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

    Xceed Support
    Member
    Post count: 5658

    My apologies, BeginEdit on Cell is not overridable. You will need to override BeginEdit on DataRow instead.

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

    User (Old forums)
    Member
    Post count: 23064

    I am realy sorry. in that post there in no BeginEdit It shows me how to create cell , row and associating these with grid. To stop editing i should call EndEdit inside BeginEdit ??

    Imported from legacy forums. Posted by sethu (had 458 views)

    Xceed Support
    Member
    Post count: 5658

    class CustomDataRow : Xceed.Wpf.DataGrid.DataRow
    {
    public override void BeginEdit()
    {
    // do the verification you want here. If it fails, throw an exception
    throw new DataGridException( “Can’t edit the cell” );

    // if everything was fine, call base
    //base.BeginEdit();
    }
    }

    class CustomDataGridControl : Xceed.Wpf.DataGrid.DataGridControl
    {
    protected override DependencyObject GetContainerForItemOverride()
    {
    return new CustomDataRow();
    }
    }

    CreateCell does not need to be overridden if you are not providing a custom cell.

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

    User (Old forums)
    Member
    Post count: 23064

    Instead of throwing exception . if the validation falis i set the base.IsEnabled = false

    thank you so much

    Imported from legacy forums. Posted by sethu (had 5819 views)

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