DataGridView VB Editable Cells

7
Hello, I have a DataGridView that is populated by a BindingSource and when I load the data I can not edit the Cells with value, only when I load the empty DataGridView, I tried to use DataGridView1.BeginEdit(True) but it does not work!

Code:

 Private Sub CarregarDataGrid()
    Try
        DataGridView1.DataSource = Nothing
        DataGridView1.AutoGenerateColumns = False
    Catch ex As Exception
        MsgBox("Erro ao Limpar o DataSource do DataGridView")
        Exit Sub
    End Try
    strsql = "select * from Usuarios"

    Dim objCommand As New MySqlCommand(strsql, conn)
    Dim dr_temp As MySqlDataReader
    Dim bs_temp As BindingSource = New BindingSource

    Try
        dr_temp = objCommand.ExecuteReader()
        bs_temp.DataSource = dr_temp
        DataGridView1.DataSource = bs_temp
    Catch ex As Exception
        MsgBox("Erro")
        Exit Sub
    End Try

    confiDataGrid()
End Sub

Configure DataGrid:

Private Sub confiDataGrid()
    If btnManutencao.BackColor = Color.Silver Then
        DataGridView1.AutoGenerateColumns = True
        With DataGridView1
            Try
                .Columns(0).HeaderText = "Codigo Usuario"
            Catch ex As Exception
                MsgBox("Erro")
                Exit Sub
            End Try
            .Columns(1).HeaderText = "Observações"
            .Columns(2).HeaderText = "Data Registro"
            .AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
        End With
    End If
End Sub

I'd like to know just how to make it editable by clicking on the cell. Thank you!

    
asked by anonymous 25.05.2015 / 21:27

1 answer

1

Try adding the line:

DataGridview1.ReadOnly = False

After your DGV is populated. On this basis it will allow the same to be edited.

    
13.11.2015 / 13:51