public partial class MainForm : Form
{
public void refreshInventoryDGV()
{
// function that will be used in other form
}
private void addButton_Click(object sender, EventArgs e)
{
// need to pass "this" form instance to other form
ItemForm addItemForm = new ItemForm(this);
addItemForm.Show();
}
public partial class ItemForm : Form
{
private MainForm fromForm { get; set; }
public ItemForm(MainForm thatForm)
{
InitializeComponent();
// set the "this" instance of main form
fromForm = thatForm;
}
private void saveButton_Click(object sender, EventArgs e)
{
// function from main form
fromForm.refreshInventoryDGV();
}
Last active
October 19, 2023 16:21
-
-
Save jgram925/e964acac035492673d4f0dddf264525c to your computer and use it in GitHub Desktop.
C# Winform - Calling a form function from another form.md
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
just wanted to say thanks, this helped me out in my application