Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How-To:MacroSubsitution
Message
De
07/07/2007 11:03:01
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01238242
Message ID:
01238385
Vues:
7
Kirk,

What you need is reflection. Here's something to get you started:
string DLLName = "MyDLL.dll";
string ClassName = "MyClass";
System.Reflection.Assembly oDLL;
object oClass;

// This "loads" the .DLL
oDLL = System.Reflection.Assembly.LoadFrom(DLLName);

// This creates the class instance
oClass = oDLL.CreateInstance(ClassName);
~~Bonnie






>I have a listbox on a form, when the user select an item in the list, I want to run that report. The reports are based off report classes (active reports). I'd like to have it dynamic so I can just pull the name from the listbox and run it, and not setup a big case statement. But I don't know how to replace the line that creates the report object (rpt_sch_Standard_Schedule in the example below.
>
>Any help appreciated.
>
>Thanks
>Kirk
>
>
>        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
>        {
>            string myRptClassName;
>            myRptClassName = listBox1.Text;
>            string myCommand;
>            myCommand = myRptClassName.Trim() + " rpt = new " + myRptClassName.Trim() + "()";
>
>            //Need to replace next line with some type of
>            //macro substitution based off the value in the myRptClassName variable
>            // foxpro would be
>            // myCommand=allt(myRptClassName)+[ rpt = new ]+allt(myRptClassName)+[()]
>            // &myCommand
>
>            rpt_sch_Standard_Schedule rpt = new rpt_sch_Standard_Schedule();
>
>            this.viewer1.Document = rpt.Document;
>            rpt.Run();
>
>        }
>
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform