Adding new user control programmatically in windows forms

后端 未结 3 1558
礼貌的吻别
礼貌的吻别 2021-01-21 00:37

Hey so first off i would like to point out that I know that there are several other questions about this topic up here, I have even done this exact thing myself before. I am ask

相关标签:
3条回答
  • 2021-01-21 01:02

    Add your user control to the form:

    home.Controls.Add(t_ES);
    
    0 讨论(0)
  • 2021-01-21 01:03

    Either make entry suggestion inherit the form class or add it to an existing form using form.Controls.Add. Remember, it's a user control, not a user form, thus it cannot support itself, it needs a container and ultimately it has to have a form containing it somewhere.

    0 讨论(0)
  • 2021-01-21 01:15

    You need to add your user control to the display surface of the main form (or another container already present)

        MainScreen home = new MainScreen();
        home.Show();
        EntrySuggestion t_ES = new EntrySuggestion();
        home.Controls.Add(t_ES);
    
    0 讨论(0)
提交回复
热议问题