• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

visual basic: updating window's form when closing another

nikefido

n00b
Joined
Feb 29, 2004
Messages
55
Hi - Me and my project partners are coding a program for this project...

To put this simply:
We have a windows form with a listbox that populates from a column in a data table...

We have a second form to add items to that data table column (that's a gross simplification but has the same end result)

When this 2nd form closes, we would like to first form's listbox to update (to call the tableadapter.fill or likewise method)

I made a button on the 2nd form telling the first form to to do the fill method (my.forms.form1.___tableadapter.fill(etcetc.etcetc)

However, this button does not work. Also, the FormClosing method with the same code does not work.


Can anyone point me to some ideas on how to update a form in this manner using buttons or actions from another form? The obvious ways don't seem to be working for me :(
 
You'd be better off in the programming forum.

Is the second form modal? If so, simply call the method you want when the modal form returns success.

If it's not modal, you'll need to have the second form call a public method on the instance of the first form that needs updating. That further means the second form needs a reference to the first form, so the first form will have to provide a reference to itself when creating the second form and the second form will need to hang on to that reference in its member data.
 
look into using Events and pass data back in the "sender" parameter or create a custom delegate and event and you can create whatever signature you want (including custom objects)
 
Here's another way.

Create a public property on Form2.

Create the object reference in Form1

show form2

once it closes, acess the property from Form1
 
Back
Top