Search code examples
vb.netvisual-studioshowdialog

How to open a frmWindow a second time wothout refreshing a grid in the first one?


I have a Window with a Grid that is making a select from MySQL, 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?


Solution

  • 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.