Forms Navigation

  • Thread starter Thread starter a
  • Start date Start date
A

a

i have 1 form that starts up and stays loaded, while loading and
unloading other forms on top of it:

_first form---------------

public static Form fromForm;

public static void appNav(Form toClose, Form toOpen)
{
toOpen.Show();
toClose.Dispose();
}

so i can load, close forms in other forms by calling:

_first.appNav((this, new FormWhatever());

fine.

but if i want a form to go 'back' to a form dynamically i am having
problems.

so when i load a form, I am trying to set the _first.fromForm by:

_first.fromForm = this;

then i try calling the appNav function:

_first.appNav(this, new _first.fromForm());

So i am trying to go back to the form that was previously loaded by
using the static form in _first, which is set when a form loads...

but it doesn't work. Any suggestions?
 
ok so i found this thread:

http://groups.google.ca/group/micro...f87a1?hl=en&q=compact+framework+get+form+name

...and i created a simple project in VB to test Alex F's method and it
works.

but i created a simple project in C# to test the method and it fails
on the line '..Activator.CreateInstance(tForm)'

.... i get an error: cannot implicity convert type 'object' to
'System.Windows.Forms.Form'

i am not mis-spelling anything in the code or anything like that.

So how come it works in VB but not C#?
 
again, to answer my own question, i found the solution here:

http://www.eggheadcafe.com/community/aspnet/2/10107196/re.aspx

...the key being the line where it uses and object, not form, to create
the instance. Then in my nav function i use:

appNav(this, Form(newform))

still not sure why it works in VB the other way. I think maybe with VB
the form Name property is accessible to GetType whereas in C# it's
not? If so, then it maybe then can auto translate it from an object to
a form?
 
Back
Top