Charlie Stuart Charlie Stuart - 2 years ago 103 Question

Making one column in DataGridView read only

Within my program i have included a datagridview that is filled when the form loads. When it first loads i have set the whole form to read-only. However if the user then wants to edit the data within it they can click an edit button i have included on the form, this has the code:

datagrdSnippets.AllowUserToDeleteRows = True 'Allows user to delete rows
datagrdSnippets.ReadOnly = False 'Allows user to edit cells within the data grid

However i do not want one of the columns within the datagridview to be made editable, what code can i use to do this?

Answer Source
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Column1.ReadOnly = True
        Column2.ReadOnly = True
        Column3.ReadOnly = True
End Sub

set readonly true your desired column on form load event

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download