@Jamie Hayashi , Welcome to Microsoft Q&A, you could try to use Application.OpenForms Property to get what you wanted.
Here is a code example you could refer to.
Form1:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 form = (Form2)Application.OpenForms["Form2"];
form.UpdateGridView();
}
private void Form1_Load(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.Show();
}
}
Form2:
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
public void UpdateGridView()
{
dataGridView1.Rows[1].Cells[1].Value = 23;
}
private void Form2_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("Name");
dt.Columns.Add("Age");
dt.Rows.Add("test1", 22);
dt.Rows.Add("test2", 32);
dt.Rows.Add("test3", 12);
dataGridView1.DataSource= dt;
}
}
Result:
Hope this could help you.
Best Regards,
Jack
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.