I'm kinda stuck and not sure how I should go about this.
I have a form where I collect some information, and the user clicks a button to save the info to a datagridview control. The problem is that the datagridview is in another form.
I initially tried to pass the information using the following code, but it won't work because the target method needs to be static, and I can't make it static (so far as I know) because that method calls another method on an object, and a static method cannot reference an object.
\
private void toolStripButton1_Click(object sender, EventArgs e)
{
string[] ingredient = {this.AddIngredient_Quantity.Text + " "
this.AddIngredient_Unit.Text,
this.AddIngredient_Ingredient.Text,
this.AddIngredient_Format.Text };
EditRecipe.addIngredient(ingredient);
}
This code is in a form called AddIngredient.cs, and as you can see, the information is to be added to EditRecipe.cs. The following is what I have so far for code:
public static void addIngredient(string[] ingredient)
{
ingredients.Rows.Add(ingredient);
}
This cannot work because EditRecipe.ingredients is an instance of DataGridView.
How can I possibly hack this to accomplish my goal?