I am using Windows Forms on .NET 4.5.2. I have 2 Forms. Form1 has a DataGridView that contains field from database and a button that shows Form2 when clicked. Form2 has a TextBox. I want to fill it with text from one of Form1 DataGridView fields when I click a button in Form1. Is it possible? The Form2 Textbox modifier is set to public but it is still not working.
I have tried:
private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
Form2 fr = new Form2();
int row = DataGridView1.CurrentRow.Index;
fr.Textbox1.Text = Convert.ToString(DataGridView1[0, row].Value);
fr.Textbox2.Text = Convert.ToString(DataGridView1[1, row].Value);
}
private void button1_Click(object sender, EventArgs e)
{
Form2 fr = new Form2();
fr.ShowDialog();
}