I try it has not succeeded if I uncomment for the code DataGridView2.Columns("Qty").ReadOnly = True
then it can be editable but all rows in one column but I want to be editable in the row I select after I click edit and if I move another row then it is readonly
Please Guide me
Thanks
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
DataGridView2.DataSource = itrservice.GetLoadStocksoutdetailMaster()
DataGridView2.Columns("No").ReadOnly = True
DataGridView2.Columns("Invnop").ReadOnly = True
DataGridView2.Columns("CodeProduct").ReadOnly = True
DataGridView2.Columns("Qty").ReadOnly = True
End Sub
Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
If e.ColumnIndex = 4 Then
If DataGridView2.SelectedRows.Count = 0 Then
Return
End If
DataGridView2.Columns("Qty").ReadOnly = False
End If
End Sub
view datagridview

The
DataGridViewCellinherits theReadOnlyproperty from its owning column or row. Setting the property toTruemeans you can't use the cell'sEditingControlto change the value and it's only can be changed by code.You can instead set the
DataGridView.EditModeproperty toDataGridViewEditMode.EditProgrammaticallyto disable putting the cells in edit mode by the mouse and key inputs. By code in theCellContentClickevent handler, select and put a given cell in edit mode when you click the link cell of the selected row.Example to put the
Qtycell in edit mode.You can use the columns
Nameproperty to identify them instead of the index..Another example on how you should populate the grid and add the
DataGridViewLinkColumn.Side note, IMO the
FullRowSelectis not appropriateSelectionModehere. Use the defaultRowHeaderSelectvalue instead.