Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Calling a form whose name is not known at compile time from another form

$
0
0

I have been trying to get a way of calling a form whose name is not known at compile time, from another form.

i.e., Form HO_MAIN presents a list of options to the user.

The selected option calls form ADDMODDEL with a string parameter that is the option (STATEMASTER or REGMAST or QLTYMAST etc) the operator selected.

Form ADDMODDEL gets the user option (ADD/MOD/DEL), and then has to call the form whose name was the string parameter received, with the ADD/MOD/DEL option.

I have tried a lot of options; but all have failed: mostly   "Message=Could not load type 'STATEMASTER' from assembly 'HO_Appln, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'."

I have used Getexecutingassembly (and callingassembly and entryassembly also) to no avail.

In the form ADDMODDEL, I have used :

ublic Class addmoddel
    Dim amdin As String
    Dim fname As String = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name
    Dim amdopt as String

This presents the assembly name and form name.

Is there anyway I can call the form whose name is in string AMDIN (e.g. "STATEMASTER") with the option in string AMDOPT (e.g. "D") ? Both AMDIN and AMDOPT will be known only at runtime.

I have for the moment given up and hardcoded the calls; but it is rather (Very) ugly.

Is it possible at all?

Thanks

Mohan


MohanSQL


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>