what I try to do is take a complete row of a DataGridView and show it in another form, it's for a search button, I want to write the name and when I select it in the gridview and press the button, that data appears in another form . Here is the Datagrid from which I will extract the row:
string Nombre, Id, fecha;
double Sueldo, incentivo, result;
DataGridView filas;
public Form5(double subru, string nom, string id, double incen, string fech, DataGridView filas, double resultado)
: this()
{
result = resultado;
Nombre = nom;
Id = id;
Sueldo = subru;
incentivo = incen;
fecha = fech;
this.filas = filas;
}
private void Form5_Load(object sender, EventArgs e)
{
}
private void button4_Click(object sender, EventArgs e)
{
if (MessageBox.Show("¿Desea Salir?", "Salir", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
{
Application.Exit();
}
}
private void button1_Click(object sender, EventArgs e)
{
Form1 fd = new Form1(dgv2);
fd.Visible = true;
Visible = false;
}
private void btndatos_Click(object sender, EventArgs e)
{
if (filas != null)
{
for (int i = 0; i < filas.Rows.Count - 1; i++)
{
DataGridViewRow clonedRow = (DataGridViewRow)filas.Rows[i].Clone();
for (Int32 index = 0; index < filas.Rows[i].Cells.Count; index++)
{
clonedRow.Cells[index].Value = filas.Rows[i].Cells[index].Value;
}
dgv2.Rows.Add(clonedRow);
}
}
dgv2.Rows.Add(fecha, dateTimePicker2, dateTimePicker3, Id, Nombre, Sueldo, incentivo, result);
}
}
}