Best regards, how I can delete a record in the DataGridView and update this table len but removing it would be activating a checkbox and pressing a button.
your attention is appreciated

Is the DGV databound?

When you say it would be activating a checkbox and pressing a button, do you mean:

1) The user presses a check box
2) The user presses delete

or

1)The application fires off a checkbox
2)The application fires off a button_click event

I mean:
actuivar the press box and a command button to delete the selected record only

Help

I think the OP is using a translator service to post in english and something was lost in the translation.

This is my understanding of your goals:

  1. There is a CheckBox that enables/disables a Delete Button.
    2a. Clicking the button will delete the selected rows from the DataGridView
    or
    2b. Clicking the button will delete row that has focus.

    Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Button1.Enabled = CheckBox1.Checked
    End Sub

    ' ***************************
    ' Enable one of these button handlers. Not both

      'Private Sub Button1_ClickV1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      '   ' deletes all seleted rows
      '   For i As Int32 = DataGridView1.SelectedRows.Count - 1 To 0 Step -1
      '      DataGridView1.Rows.Remove(DataGridView1.SelectedRows(i))
      '   Next
      'End Sub
    
      'Private Sub Button1_ClickV2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      '   ' deletes the current row
      '   If DataGridView1.CurrentRow IsNot Nothing AndAlso (Not DataGridView1.CurrentRow.IsNewRow) Then DataGridView1.Rows.RemoveAt(DataGridView1.CurrentCell.RowIndex)
      'End Sub
    

    ' ***************************

      Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
         Button1.Enabled = CheckBox1.Checked
      End Sub
    

    End Class

i cant get your point ,i think you want to delete the selected record from the grid and also from db. you can do this on button click event after selecting your row from grid.

dim con as new sqlconnection("your connection string")
con.open()
dim cmd as new sqlcommand()
cmd.connection=con
cmd.commandtext="delete from table where recordid=" + datagrid.item("recId",datagrid.selectedIndex).value.tostring()
cmd.executenonquery()
con.close()
datagrid.rows.remove(datagrid.selectedindex)
'in this code recid is  assumed by me as it is present in your grid.

may be there are some spelling mistakes or other issues as i am from my phone. but hopefully you can get the idea .

apology for not translate well, I speak Spanish

I have a form with three DataGridView.
In the first two columns with checkbox and 5 columns with data, when I activate the check either the first or second column and pressing a button on the form of the record is deleted and added to DataGridView1 DataGridView2 that is where you want the deleted record of DataGridView1 is updated in the table (delete it).
I can select more logs and delete them (removing multiple)
I hope you can understand and help me

apology for not translate well, I speak Spanish

No need to apologize! I only pointed that out hoping that people may be a little bit more understanding. Sometimes it helps for you to post your question in your native language followed by an English translation. But please always include an English translation.

Does any of what we have shown, help?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.