locked
DataGridViewCell.ReadOnly doesn't work RRS feed

  • Question

  • Hi

    I've tried 
        dgvMyGrid.Rows[3].Cells[2].ReadOnly = true
    and
        dgvMyGrid.Rows[3].Cells["ColumnName"].ReadOnly = true

    but neither work.

    Code compiles and runs, but has no efect.

    Thanks,
    Nigel
    Friday, June 6, 2008 10:23 AM

Answers

  • Funnier still is the MSDN help in VS2005 for DataGridViewCell.ReadOnly Property
    "

    Property Value

    true if the cell's data can be edited; otherwise, false.

    "

    So you set ReadOnly to true if the cell's data can be edited?  Then you set it to false and the cell is no longer ReadOnly?
    Frustrating to say the least!

    If you're binding to a DataTable, you can set that table's column to be read only.  That has the major downside of making all cells in that column read only.

    Jebrew


    • Marked as answer by Nigel Mackay Saturday, June 7, 2008 5:53 AM
    Friday, June 6, 2008 8:13 PM

All replies

  • Funnier still is the MSDN help in VS2005 for DataGridViewCell.ReadOnly Property
    "

    Property Value

    true if the cell's data can be edited; otherwise, false.

    "

    So you set ReadOnly to true if the cell's data can be edited?  Then you set it to false and the cell is no longer ReadOnly?
    Frustrating to say the least!

    If you're binding to a DataTable, you can set that table's column to be read only.  That has the major downside of making all cells in that column read only.

    Jebrew


    • Marked as answer by Nigel Mackay Saturday, June 7, 2008 5:53 AM
    Friday, June 6, 2008 8:13 PM
  •  Unfortunately, it is just some of the columns in one particular row.

    So I will have to reject all attempts to edit the cell's contents.

    This is confusing for a user who can't remember that those values are supposed to be read-only, as it looks as if something is going wrong!!
    Saturday, June 7, 2008 5:56 AM