-
-
Save Scribbio/f823a4e5bf397a0742143ba1d19640af to your computer and use it in GitHub Desktop.
Revisions
-
Scribbio revised this gist
Aug 26, 2019 . 1 changed file with 11 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,14 @@ LOADING ASSETS FROM REFERENCED PROJECTS DYNAMICALLY --CONTEXT------------------------------------------------------------------------------------------------- For example, you have a winforms application and you reference other winform projects which deal with specific sections of your application. These sections are accessible through a single menu, in our example a listview (named LvAdministration) We can load a particular form from one of these projects depending on the user's selection during run-time. The listview has two columns, represented by "|", the second is hidden. @@ -31,25 +30,19 @@ | | ------------------------------------------------------------ --HOW TO DO IT------------------------------------------------------------------------------------------------- Handle the listview's click event. Private Sub LvAdministation_Selection(ByVal eventSender As System.Object, ByVal e As EventArgs) string dllName = "UserForms"; var loadedClassFromDll = Assembly.Load(dllName).CreateInstance(strObjTmp); loadedClassFromDll.Show(); Dim nspc As String = strObjTmp.Substring(0, strObjTmp.LastIndexOf("."c)) Dim o As Object = Nothing clsObjet = Assembly.Load(nspc).CreateInstance(strObjTmp) @@ -69,6 +62,7 @@ Case "Impression" clsObjet.Imprimer(strTable) End Select End Sub -
Scribbio revised this gist
May 17, 2019 . No changes.There are no files selected for viewing
-
Scribbio revised this gist
May 17, 2019 . 2 changed files with 76 additions and 51 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,76 @@ LOADING ASSETS FROM REFERENCED PROJECTS DYNAMICALLY If you have other projects loaded in your project. For example, you have a winforms application and you reference other winform projects which deal with specific sections of your site. These sections are accessible through a single menu, in our example a listview. We can load a particular form from one of these projects depending on the user's selection during run-time. The listview has two columns, represented by "|", the second is hidden. FIGURE 1 - Form ADMINISTRATION |----------------------------------------------------------| | ADMINSTATION | |----------------------------------------------------------| | | | |Listview | | ---------------------------------- | | |Add Users | UserForms| | | |Delete Users | UserForms| | | |Manage Users | UserForms| | | |Add Invoice | FinanceForms| | | |Manage Payrolls | FinanceForms| | | |Order Stock | UserForms| | | |Delete Stock | UserForms| | | |Manage Users | UserForms| | | | ------------------------------------------------------------ You can handle the click event with the following function. Private Sub lvwUtilisateurs_Selection(ByVal eventSender As System.Object, ByVal e As EventArgs) String form = string dllName = "UserForms"; var loadedClassFromDll = Assembly.Load(dllName).CreateInstance(strObjTmp); loadedClassFromDll.Show(); Dim nspc As String = strObjTmp.Substring(0, strObjTmp.LastIndexOf("."c)) Dim o As Object = Nothing clsObjet = Assembly.Load(nspc).CreateInstance(strObjTmp) clsObjet.frmFenMDI = FMdiBal strTable = lvwMenu.clsSubItems("FctCod").Text Select Case strTypeFonction Case "Consultation" clsObjet.Consulter(strTable) Case "Proposition" clsObjet.Saisir(strTable) Case "Hors Proposition" clsObjet.Saisir(strTable, strAcces) Case "Tables de référence" clsObjet.Table(strTable, strAcces) Case "Impression" clsObjet.Imprimer(strTable) End Select
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,51 +0,0 @@ -
Scribbio created this gist
May 16, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ For example, if you have a dll of name "UserForms" referenced in your project it can load it dynamically And you have a menu which contains a list of sections , the user clicks on a item and it will load the required form from the required dll. USERFORMS ManageUsers | UserForms ------ You can handle the click event with the following function. Private Sub lvwUtilisateurs_Selection(ByVal eventSender As System.Object, ByVal e As EventArgs) String form = string dllName = "UserForms"; var loadedClassFromDll = Assembly.Load(dllName).CreateInstance(strObjTmp); loadedClassFromDll.Show(); Dim nspc As String = strObjTmp.Substring(0, strObjTmp.LastIndexOf("."c)) Dim o As Object = Nothing clsObjet = Assembly.Load(nspc).CreateInstance(strObjTmp) clsObjet.frmFenMDI = FMdiBal strTable = lvwMenu.clsSubItems("FctCod").Text Select Case strTypeFonction Case "Consultation" clsObjet.Consulter(strTable) Case "Proposition" clsObjet.Saisir(strTable) Case "Hors Proposition" clsObjet.Saisir(strTable, strAcces) Case "Tables de référence" clsObjet.Table(strTable, strAcces) Case "Impression" clsObjet.Imprimer(strTable) End Select