winforms - Can a C# solution have multiple forms, but have one selected to be the main when compiled? -
basically, program want have common backend, have can compile different gui control program. know can make multiple forms, there way tell solution compile, , form1 gui, , later, compile , tell form2 gui (and not include form1 in compiled program).
form1 more administrator more features, while form2 normal user far less capabilities form1. possible, or have make new solution?
yes, can use conditional compilation , exclude code compile entirely. can similar to:
#if user_gui public class basicform : form { // ... } #endif and
#if admin_gui public class advancedform : form { // ... } #endif then have similar #ifdef when starting gui call approriate constructor
public static void main(string[] args) { // ... #if user_gui var form = new userform() #endif #if admin_gui var form = new advancedform() #endif application.run(form); } when compile, can set project properties appropriate variable in project -> properties -> build -> conditional compilation symbols, , add either user_gui or admin_gui
Comments
Post a Comment