Navigation Fails in Forms!!!!!!!!!!!!!!!!

G

Guest

Hi,

In my application(vb.net-pocket pc), there are 3 forms. From the first
form, I am using the following code to show the second screen.

form2.showdialog

from the sencond form to third, form3.showdialog is used.

from the third to the first form, form1.show dialog is used.

But I am not able to get the past instances of my previous forms. And
sometimes it hangs. I have tried several things like
form2.visible =true
form2.hide
form2.visible =false
form2 = new frmSecond
etc etc..................................

Please tell me how to navigate correctly between VB.Net forms and I wish to
get the previous instances of the forms. Also I wish to hide certain forms,
while coming back. Suppose 5 items are in my list box in a form. When I am
showing that form again, no items are displayed in the list box.

I dont know what happend. Please Help Me. Very Very urgent.
Without creating new instances of forms, how to show the forms with changing
data in their text boxes.???

I am getting carried away because of this. I dont know what happend
 
D

Darren Shaffer

Hari,

You can convert the C# code below to VB.Net. Add it to all 3 of your forms.
To show any form that implements this pattern while one of the others is
visible,
all you need to do is call FormName.GetInstance().Show(); (replace
"FormName"
with the actual name of the form you want to show)

-Darren Shaffer

public class HarisForm : System.Windows.Forms.Form
{
private static HarisForm instance;

// singleton pattern
public static HarisForm GetInstance()
{
if ( instance == null )
{
instance = new HarisForm();
}
return instance;
}
 
G

Guest

Dear Darren,

Thanks for your reply.
I am using the following code for displaying another forms.

Try
gFrmForm1 = Me 'passing the current instance to
global variable

If gFrmForm2 Is Nothing Then
gFrmForm2 = New Form2
End If
gFrmForm2.ShowDialog()
Catch
End Try

First time the code is executed, there is no problem. In the second round,
if the same button is pressed for displaying Form2, Form2 is displayed, but
the form hangs/freezes. And if I am closing the form(Maximize to False, so
only OK button is there for closing), System.Argument Exception is generated
in a form.

Please Help.
Hari
 

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