Can I specify which Columns are editable in a WPF DataGrid?

后端 未结 4 887
Happy的楠姐
Happy的楠姐 2021-01-02 15:05

I have a WPF 4.0 DataGrid with AutoGenerated columns. I would like to only allow the user to edit the first column. Is there an easy way of doing this?

I was trying

4条回答
  •  自闭症患者
    2021-01-02 15:53

    private void dgTableDetailAdj_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
    {
        foreach (DataGridColumn col in dgTableDetailAdj.Columns)
        {
            if (col.Header.Equals("columnName"))
            {
                col.IsReadOnly = true;
            }
        }
    }

提交回复
热议问题