Well here is the explanation -
I have a listbox1 in main form containing product lists. Now I allow the
user to add new products in the second form and when they close the second
form - the main form should update the new product items in the Listbox1
under main form. And I don't know what is the best way to do it.
Thanks
Then, IIUC, you need to handle FormClosed event which is raised after
form is closed. But, curious, why do you mean by "refreshing"? Adding
new items or using Refresh method which redraws the control? Because
as you re-open your form, it may be needless to call Refresh method
based on your implementation.
Thanks,
Onur Güzel
Well, then you need to add new items of second form's listbox
items(items which will be added to the entire product list) into main
form's listbox. So, you'd better handle FormClosing event of second
form and add all the items to the main form's listbox before second
form is closed, as follows:
'----Begin------
'Add second form's listbox items into entire list
'which are located in mainform's listbox.
'Put the code in your second form
Private Sub SecondForm_FormClosing(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.FormClosingEventArgs) _
Handles MyBase.FormClosing
MainForm.mainforms_listbox.Items.AddRange(Me.secondforms_listbox.Items)
End Sub
'----End------
...where "MainForm" is the name of your main form, "mainforms_listbox"
is the name of your main form's listbox, "second_form" is the name of
your second form and "secondforms_listbox" is the name of your second
form's listbox.
Hope this helps,
Onur Güzel