Open form with Form Name in winform appliaction

前端 未结 2 704
猫巷女王i
猫巷女王i 2020-12-19 21:58

I want to ask what should i do to open form with the help or class name in winform c#?

I have three different forms

  • UserManagement
  • GroupsManag
2条回答
  •  臣服心动
    2020-12-19 22:43

    You may be able to do something like this, using the name of your form, as a string argument:

    var form = (Form)Activator.CreateInstance(Type.GetType("YourNameSpace.UserManagement"));
    form.Show();
    

提交回复
热议问题