I am having problem with the fallowing piece of code

foreach (DataGridViewRow Rows in prePDDataGridView.Rows) {

Rows.DefaultCellStyle = null;

Rows.ReadOnly = true;

DataGridViewDisableButtonCell buttonCellSave =
(DataGridViewDisableButtonCell)Rows.Cells["Save"];

buttonCellSave.Enabled = false;

}

The above code will make all the rows in data grid view as readonly and the
button cell to disable.

The above code works properly when i made the form as non MDI child.

But it does not work if i made the form as MDI Child.

I dont know what is the reason. Any solution for this ?