C# winforms event in Main method for any new form shown -


i have 2 windows forms apps projects (one test , 1 prod) , dll project in same solution. 2 winforms app projects have 1 class/function, program.main(), icons i'm asking about, , app.config files. both reference same dll contains else (including forms).
want able set icon (form.icon) , text (form.text) each time new form in app shown. purpose of have different window titles , icons test , prod (as different publish location settings). how can accomplish this? i've tried setting icon properties>application>resources>icon , manifest, doesn't work. happy getting different icon, text big plus. there event subscribe in program.main() method, before application.run(new form()), can set icon , text properties form shown, or other solutions? edit: hoping somthing because there lots of forms:

    static void main()     {         application.enablevisualstyles();         application.setcompatibletextrenderingdefault(false);         someclass.newwinformshown += newwinformshown;         application.run(new frmtrackinglist());     }      private static void newwinformshown(object sender, newwinformshowneventargs e)     {         e.newwinformshown.icon = thisappsicon;//from resources         e.newwinformshown.text += " (test)";     } 

you can create baseform forms use in application, not hard

public class appform : form {     public appform()     {         initializecomponent();         this.icon = myappsettings.appicon; <--read here         this.text  = "app text"     } } 

edit: accessing icon in dll, create static class in dll , use it

//in dll project public static class myappsettings {      public icon appicon {get;set;} }  //in exe project static void main() {     myappsettings.appicon = resources.icon;  <--set here     //rest of starting app code goes here } 

then make form derive appform. should solve problem.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -