Reputation: 125
I have a user control called home that has the location already set. When I dynamically create it below I don't see it. I've tried setting the property to visable using the show and bring to front method but nothing. What am I missing?
namespace TipManager { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); form = new Form1(); Application.Run(form); TipManagerModel tipManager = new TipManagerModel(); TipManagerServices services = new TipManagerServices(tipManager); Home homeView = new Home(); HomePresenter homePresenter = new HomePresenter(homeView, tipManager, services); form.Controls.Add(homeView); homeView.BringToFront(); } static Form1 form; } }
Upvotes: 1
Views: 76
Reputation: 1664
The form is being called before adding the control, move Application.Run(form);
to the end of the function. On a side note, I would highly recommend doing this in the form constructor after InitializeComponents();
rather than doing it here.
Upvotes: 1