Open a Form

F

Franck

I'm a vb programmer but i have to touch C# a bit now. I'm looking for
a thing that doesn't seems to exist anywhere here im talking of how to
open a form.

in vb it was just frmMyform.show or frmMyform.load and after showing
it.
Ive search the web for that and it always came out with like 2 to 5 of
code lines that's completely stupid

i have tred all them and they all create a brand new form that doesnt
even exist and never manage to open my form. It seems that everyone is
building their form at runtime.

here's the one that i was thinking it would have work but no

frm frmResults = new frm();
frmResults.show();

i tried also instead of show : .ShowDialog(); i even try load even it
wasnt in event list.
 
P

Peter Duniho

Franck said:
I'm a vb programmer but i have to touch C# a bit now. I'm looking for
a thing that doesn't seems to exist anywhere here im talking of how to
open a form.

in vb it was just frmMyform.show or frmMyform.load and after showing
it.

And in VB, how did you initialize the variable "frmMyform"?
Ive search the web for that and it always came out with like 2 to 5 of
code lines that's completely stupid

i have tred all them and they all create a brand new form that doesnt
even exist and never manage to open my form. It seems that everyone is
building their form at runtime.

Even in VB, your form doesn't exist until runtime. How could it?

VB may be hiding the instantiation of the Form-derived class from you.
It may put the reference to the instantiated class in a global variable
for you. But rest assured, there's no form until you run your program.
here's the one that i was thinking it would have work but no

frm frmResults = new frm();
frmResults.show();

This is the usual way to instantiate _and_ show a form.

You are not very clear on what about the above code doesn't work for
you. But if you want to simply show a previously hidden (but not closed
or disposed) instance of a form, the simple answer is that you need a
reference to that form somewhere.

How you do this is up to you. There have been a number of threads on
this very concept in this newsgroup, so Google Groups should be able to
help you out there.

If you are having a problem other than simply obtaining the reference to
a form instance that already exists, then it would help for you to ask
your question in a more specific way. A concise-but-complete example of
code demonstrating your problem would be helpful.

Pete
 
F

Franck

i said it.
in vb you just for example put a simple button on a form and you
double click it to get to the click event
and in it you jsut write these 2 words

frmMyform.show

thats it and bang your form in your project named frmMyform open up in
front of your eyes, it not that complicated it can't be easier
if you take example of the code i put in my other message it's the one
i tought that would work best but it's 2 lines it's really long for
opening a single form. OHHH for openning a for it does open a form i
don't know where he take his frmResult there but it wasnt mine. All
other codes ive tried are creating a brand new form that popup you.

In other word, do you always code a program in 1 form or you use
multiple one ? i wish you use more than 1, so how do you pass from one
to the other.
 
F

Franck

i solved my problem i wrote the code in vb instead and it worked.
Maybe because there is small difference in the c# version of visual
studio 2005
 
G

Guest

When you say, in VB it was just frmMyForm.show, you are probably talking
about VBA or VB 6. In .net (VB and CSharp), the minimum code, I believe,
would be:

// csharp
ui = new frmMyForm();
ui.Show();

' vb
ui = New frmMyForm()
ui.Show()

If your code like above was not working, then I would suspect there was an
error in the form initialization.
 
F

Franck

When you say, in VB it was just frmMyForm.show, you are probably talking
about VBA or VB 6. In .net (VB and CSharp), the minimum code, I believe,
would be:

// csharp
ui = new frmMyForm();
ui.Show();

' vb
ui = New frmMyForm()
ui.Show()

If your code like above was not working, then I would suspect there was an
error in the form initialization.

i was talking of vb6.
but i found this morning my error, i seems that i was trying to code
in c# and vbnet at same time i mess up with the "intances of"

i wrote :
frm frmResults = new frm();
frmResults.show();

in this code i have instance a new form as frm, although i mess up the
order because the form is called frm results so i needed and instance
of frmresults and not frm
so the correct c# code was
frmResults frm = new frmResults ();
frm.show();

due that the frm form wasnt existing in project he made appear a new
non physically existing one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top