Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1770
Disabling a column
posted

Hello. I would simply like to disable a column in the XamDataGrid. I know I can do this:

((XamDataGrid)sender).FieldLayouts[0].Fields["Total"].Settings.AllowEdit = false;

but I want the column to took like if I was going to do something like this:

((XamDataGrid)sender).Records[2].IsEnabled = false;

So grayed out.

How can I do this?

Thanks

  • 17475
    Offline posted

    Hello Kris,

    I believe that setting the IsEnable property of the CellValuePresenters that are displayed in the same field, will help you achieve the functionality you need. Below is a code snippet that grey out the cells in a specific field and does not allow editing:
    foreach (DataRecord record in ((XamDataGrid)sender).Records)
                {
                    if (record != null)
                    {
                        CellValuePresenter.FromCell(record.Cells["name"]).IsEnabled = false;
                    }
                }
    I hope it will be helpful for you.