Hi, I made a cook book app.
It has a flow layout panel on the side and from it you can choose to view different recipes or write a new one.
When you choose an option the main area of the window changes by switching user controls.
The issue is when I choose to write recipe I want it to update the side menu (to show a new recipe after adding it).
The problem is that writing a recipe is in user control which is a different class than the flow layout panel so it cannot add anything to it.
Even if I make the function in the main class and call it from the user control - it wont work. It doesn't even give me an error.
I am losing my mind please someone help.
It has a flow layout panel on the side and from it you can choose to view different recipes or write a new one.
When you choose an option the main area of the window changes by switching user controls.
The issue is when I choose to write recipe I want it to update the side menu (to show a new recipe after adding it).
The problem is that writing a recipe is in user control which is a different class than the flow layout panel so it cannot add anything to it.
Even if I make the function in the main class and call it from the user control - it wont work. It doesn't even give me an error.
I am losing my mind please someone help.
Form1.cs:
public void AddRecipeButton(string recipeTitle)
{
Console.WriteLine("making a button"); //this shows up
Button btn = new Button();
var form = new Form1();
btn.Text = recipeTitle;
btn.BackColor = Color.FromArgb(232, 170, 84);
btn.Padding = new Padding(35, 0, 0, 0);
btn.Margin = new Padding(-1);
btn.FlatStyle = FlatStyle.Flat;
btn.Font = new Font("Calibri", 8);
btn.TextAlign = ContentAlignment.MiddleLeft;
btn.FlatAppearance.BorderSize = 0;
btn.Dock = DockStyle.Top;
btn.Size = new Size(250, 45);
panelM.Controls.Add(btn);
}
UserControl1.cs:
Form1 form = new Form1();
form.AddRecipeButton(RecipeTitle.Text);