Hi, I would like to cause my One of my Forms ( Parent Form ) to Reload when the Child Form closes. I know how this can be accomplised in Web Applications but not in Windows Applications. Can Anyone please tell me how?
thanks in Advance
Reaction
Printable View
Hi, I would like to cause my One of my Forms ( Parent Form ) to Reload when the Child Form closes. I know how this can be accomplised in Web Applications but not in Windows Applications. Can Anyone please tell me how?
thanks in Advance
Reaction
There's no such thing as reloading a form in a Windows app. A form is "loaded" the first time it becomes visible and never again. You could destroy the form object and create a new one but there is no possible reason for that to be required.
Presumably you mean you want the data displayed in the control(s) on a form to be updated with any changes you made in the child dialogue. If you've used data-binding properly then that will be taken care of automatically. See this thread for an example.
Even if you haven't used data-binding, displaying data in a control is simply a matter of assigning the data to be displayed to the appropriate properties of the control displaying it. For instance, if you want to display unbound data in a TextBox you simply assign that data to its Text property. That's the case whether the form is being loaded or some dialogue has just been dismissed.
What I want to do is Unload a Form and then load the forms Parent when the user clicks the Close Button on the form. Problem is I hid the parent form and instead would like to close it, open the child form and when the child form is closed, Open the parent form again as in reload it.
Me.close() does not work
vb Code:
Private Sub Vendor_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing If MessageBox.Show("Do you want to exit application completely?", "Quit Form", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then 'do nothing Application.Exit() Else 'e.Cancel = True Me.Close() End If End Sub
Can you suggest a better way to do this please?
Reaction
the closing event is triggered when the form is already being closed so I don't think that using me .close will have any effect in your program.
I would suggest that you put that code inside a button event instead of closing event of the form.
vb Code:
private sub button1_click()sender as object, e as eventArgs) Handles button1.click If MessageBox.Show("Do you want to exit application completely?", "Quit Form", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then 'do nothing Application.Exit() Else 'e.Cancel = True Me.Close() End If end sub
Can you explain your reasoning for wanting to do that? I can't think of a good reason why that would be required. It sounds like flawed design to me.Quote:
Originally Posted by Reaction
Thanks. I finally got it fixed. Basically when I open the Child Form using CHILD.SHOW() I can Close the Parent and then when I close the Child I OPen the Parent Form from Scratch and iT fixes the Problem. The Problem was that initially when I was using the Child.ShowDialog(ME), it would not update the List when I closed the Child Form. That was the reason I started searching for a reload method.
Thanks for the Help. Greatly Appreciated
Reaction