Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

i want to see if there is a way to show a form from another project according the dll name string passed by the users.

 

Public Sub ShowOneForm(ByVal dllName as String)

Dim oneForm

Select Case (dllName)

Case "FormA":

oneForm = new CustomFormA()

Case "FormB":

oneForm = new CustomFormB()

Case "FormC":

oneForm = new CustomFormC()

End Select

oneForm.Show()

End Sub

 

anyway to remove the select case block and achieve everything with one simple statement?

Posted

Once you have included a refernce to the dll in your project then you should be able to use the NameSpace of that dll to access the form.

 

NameSpace_xx.CustomFormA etc.....

Hamlet
  • Administrators
Posted

Are the forms all declared within a single Dll or in separate ones?

Either way you are probably better off looking at creating a framework for how these forms get used. One way is to define a base form in a separate dll and if anyone requires the ability to create their own forms for your app to use then the must inherit from this base form (or you could choose to define an interface - the basic idea is the same)

When your function is called they would be required to provide the fully qualified name (namspace.formname) and via the reflection API you could then load the correct dll and instantiate the form for them.

A good starting point is Divil's Plugin Tutorial as this will cover the basic ideas of what is required.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...