I would like to obtain all the values of the record in which the "delete" action applies, this should happen when I click on my columnButton.
Delete column code
private void dataTabla_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == dataTabla.Columns["btnEliminar"].Index && e.RowIndex >= 0)
{
/** Aqui surge la accion de acuerdo a la columna, en este caso la columna eliminar **/
}
}
Now I would like the values of this record to be obtained by clicking on the button.
Already I mark the index of the row, now I just need to know how I can access the data in the row with the index of it.
Update
Apparently I can already get the value and the index of my created columns that would be the buttons, but I want to obtain the value of the columns that were filled dynamically through a database.
Form of filling.
string Query = "select Id_Compra,Articulo,Categoria,Obligatorio,Costo,Adquirir from compra";
MySqlConnection MyConn2 = new MySqlConnection(connectionString);
MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2);
MySqlDataAdapter MyAdapter = new MySqlDataAdapter();
MyAdapter.SelectCommand = MyCommand2;
DataTable dTable = new DataTable();
MyAdapter.Fill(dTable);
dataTabla.DataSource = dTable;
Note: I do not know how to access them, because the indexes start from when the buttons were created and I do not know how to access the index or value of the dynamic columns
Creation of the columns of the Buttons
DataGridViewButtonColumn btnEliminar = new DataGridViewButtonColumn();
dataTabla.Columns.Add(btnEliminar);
btnEliminar.Text = "-";
btnEliminar.HeaderText = "Eliminar";
btnEliminar.Name = "btnEliminar";
btnEliminar.Width = 60;
btnEliminar.DefaultCellStyle.Padding = new Padding(2);
btnEliminar.UseColumnTextForButtonValue = true;