I know lot of similar questions are out there. But, I\'m really new to C# so, cannot figure out how to solve this.
I have a DataGridView on main form a
This is just a sample, how you call the public method in main form from child form:
public class Products : Form
{
public void UpdateProductList()
{
// do something here
}
private void buttonOpenChildFormClick(object sender, EventArgs e)
{
using (var addProduct = new Add_product(this)) //send this reference of MainForm to ChildForm
{
addProduct.ShowDialog();
}
}
}
public class Add_product : Form
{
private readonly Products _products;
public Add_product(Products products) //send reference of MainForm to ChildForm
{
_products = products;
}
private void button1_Click(object sender, EventArgs e)
{
_products.UpdateProductList();
}
}