You can not automatically generate values in DataGridView.
You can achive this by writting some queries releted your database.
Check this :
Public Function AutoID(ByVal fieldname As String, ByVal table As String)
objda.SelectCommand.CommandText = "select max(cint(mid(" & fieldname & ",4,len(" & fieldname & ")))) as maxval from " & table
Try
Dim maxId As Object = objda.SelectCommand.ExecuteScalar
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
If maxID Is DBNull.Value Then
Return 1
Else
Try
dr = objda.SelectCommand.ExecuteReader
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
If dr.Read Then
If dr(0) Is DBNull.Value Then
Return 1
Else
Return (dr(0) + 1)
End If
End If
dr.Close()
End If
End Sub
How to Use : Call it on Form_Load event
txtIdFiled.Text=AutoID("FieldName", "TableName")