1

I am displaying tables of data in a Wizard window by adding DataRows to a DataTable (which already has DataColumns), then using the .DefaultView (DataView) given from this DataTable as the .ItemsSource for the DataGrid which is shown on the page.

My problem is, I only want specific rows to be read-only, based on a value provided in one of the row's columns. For example, if in a certain row there is a column with a Yes or No value, the row will be read-only based on this. As far as I can tell, there is no way to make this DataRow read-only when you add it to the DataTable.

Is there any way to loop through the DataTable, DataGrid or DataView and set specific rows to read-only based on a value in one of their columns?

Jon Bailey
  • 93
  • 3
  • 9

1 Answers1

0

You cant make teh data object ReadOnly, but you can make the Control's Row read only.

For Each row as DataGridViewRow In DataGridView1.Rows
    If row.Value(3) = True ' 3 is just a random number as I cannot see your example
        row.ReadOnly = True
    Else
        row.ReadOnly = False
    EndIf
Next 

OR if you want a WPF answer, as I suspect, check out this.

Community
  • 1
  • 1
Sam Makin
  • 1,526
  • 8
  • 23
  • I'm not using a DataGridView, using DataGrids and DataViews, which appears to be WPF. So this is not applicable as far as I'm aware. – Jon Bailey May 23 '14 at 13:17