tags:

views:

564

answers:

3

I have a binded DataGridView where depending on some BoundItem property value that line will be read only. What is the best way to implement this? Thanks

A: 

in the rowenter event, set the readonly property of the row accordingly

private sub MyView_RowEnter(...) handles MyView.RowEnter
    MyView.Rows(e.Rowindex).ReadOnly = (condition)
end sub
GalleySlave
I thought that I should do this on some binding event
A: 

I thought that I should do this on some binding event

+1  A: 

Try The event CellBeginEdit

Private Sub Dgv_CellBeginEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellCancelEventArgs) Handles Dgv.CellBeginEdit
  If YourCondition(BoundItem.Property) then e.cancel = true
End Sub

This makes the cell readOnly depending on your condition.

x77