views:

21

answers:

2

Hy, I have a Window with a Grid that is making a select from myql, and using the .Show() function insted of ShowDialog() I can open the same window a second time to have two instances of the same window.

Now, when i open the second instance the grid populates with the new selection also in the first window....how can i make the window to open the second time without refresing the grid in it again...in the first one?

Thank you! Adrian

A: 

Form.Show is a simple function that just tells a form to unhide, it might be using the same instance hence it refreshed both.

Try this instead:

   Dim myForm As New frmMain() // Change frmMain to your forms name
   myForm.Show()
kyndigs
+1  A: 

If you are creating a new instance of the same form, based on the variable "myForm" from different locations, you are in effect going to "refresh" both forms.

One way to get around this is to create a second variable instance of your frmMain in a seperate function. (ie... not good at VB at all, so forgive my VB programming skills.)

In one function:

Dim myForm AS New formMain()
myForm.Show();

In a second function

Dim frmTwo AS New frmMain()
frmTwo.Show();

Then you just make your calls to frmTwo, which is the second form opened.

I hope this helps.

PumaSpeed