Refresh Listbox1 items

B

BlackBox

I have a Listbox1 in the main form and I can add listbox1 items in the
parent form. But when I close the parent form Listbox1 in the main form does
not get refresh. I need to re-open the app.

Any idea on how to refresh items in the main from from a parent form without
opening the app.

-Thanks
 
K

kimiraikkonen

I have a Listbox1 in the main form and I can add listbox1 items in the
parent form. But when I close the parent form Listbox1 in the main form does
not get refresh. I need to re-open the app.

Any idea on how to refresh items in the main from from a parent form without
opening the app.

-Thanks

Use "<form>.Refresh" for other forms and "Me.Refresh" for current
form.

Or depending on your wish, you can try Listbox1.Refresh method.

Onur Güzel
 
B

BlackBox

Well I forgot to mention the listbox1 should get refreshed after I close the
parent window.
 
K

kimiraikkonen

Well I forgot to mention the listbox1 should get refreshed after I close the
parent window.

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
 
I

IndiDeveloper

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

Well I forgot to mention the listbox1 should get refreshed after I close
the
parent window.

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
 
K

kimiraikkonen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top