-
[RESOLVED] Refresh/Repopulate Listview after Updating.
I have a listview(which shows users) on one form(call it form1). Its populated at form load by a sub located in form1.
I then call up another form (call it form2) to update a user. After Updating, i call the sub in form one to refresh/repopulate the listview in form1.
The listview fails to refresh. What should i do? do i need to raise an event or something else?
-
Re: Refresh/Repopulate Listview after Updating.
ideally form2 calling form1 sub ...not sure how to do that in .net though
-
Re: Refresh/Repopulate Listview after Updating.
Ggalla1779.If form1 is a public class, in form2, declare a variable as its class name, then call its methods using the variable.
-
Re: Refresh/Repopulate Listview after Updating.
is each item in the listview to represent one user?
sort of like you have a list of users, and when you double click a row, it opens form2 so you can edit that 1 user?
If that is the case, you shouldn't repopulate the entire listview because 1 row is changed, just update the 1 row itself
-
Re: Refresh/Repopulate Listview after Updating.
I forgot to add that, i wonder why Refresh function doesnt work!
-
Re: Refresh/Repopulate Listview after Updating.
Refresh only invalidates a control, which means it is repainted.. it has nothing to do with loading/unloading items from the listview.
All controls have a refresh method
-
Re: Refresh/Repopulate Listview after Updating.
Thanks Kleinma,
I click on one row, then click the update button to open another form. So when i update, i update one row. But the snag is showing the updates of that row in the listview just after updating from another form.
*****EDITS****************
When i click the update button, form1 remains visible for the user to see if his/her updates are going through.
-
Re: Refresh/Repopulate Listview after Updating.
well since all the controls in the form2 are automatically exposed to form1 (because they are declared as "friend") you can get the values entered in the edit form and update the single row. I can show you a small example if you tell me which version of VS you use
-
Re: Refresh/Repopulate Listview after Updating.
VS 2005 pro. I will be gratefull
-
Re: Refresh/Repopulate Listview after Updating.
I use the listrow technique in Access, to open and edit records then when form2 closes. There is event to detect form1 is active again.
So what Kleinma is saying is whn u close form2 u need to call form1s listviews refresh method
I found this
MainForm.updateNumbersList()
at
http://www.vbcity.com/forums/topic.asp?tid=78722&page=1
Dont know if thats what u were looking for though
-
Re: Refresh/Repopulate Listview after Updating.
Quote:
Originally Posted by Ggalla1779
So what Kleinma is saying is whn u close form2 u need to call form1s listviews refresh method
No what I was saying is that refresh has nothing at all to do with updating a listview
-
Re: Refresh/Repopulate Listview after Updating.
-
Re: Refresh/Repopulate Listview after Updating.
Its ok.. I am almost done with this sample, and then I will post the source code.
-
Re: Refresh/Repopulate Listview after Updating.
thats great...I mostly use Access databases and have only used .net 03 to display info. So I could use this in the classic List...edit... back to updated list.
cheers
-
Re: Refresh/Repopulate Listview after Updating.
Ggalla1779, thanks for the link. The helper there, describes what i want but his logic never helped.
-
1 Attachment(s)
Re: Refresh/Repopulate Listview after Updating.
-
Re: Refresh/Repopulate Listview after Updating.
Thanks. Let me take a look.
-
Re: Refresh/Repopulate Listview after Updating.
kleinma is it a 2005 sample.... my 2003 said written in newer version. I will have to wait till I get home
-
Re: Refresh/Repopulate Listview after Updating.
Yes, its in VS 2005, as the thread starter (maps) said that is what he is using.
(however there is nothing being done in the code itself that wouldn't work in 2003)
-
Re: Refresh/Repopulate Listview after Updating.
Great Kleinma. You are soooooooooooooooooooooooooooooooooooooooooo.
god....err.......good.
Thanks Man.
So this can also be done for datagrids or datagridviews!
-
Re: Refresh/Repopulate Listview after Updating.
ok ta.... I am looking at the vb code in good old notepad!!.... thanks for example!!
-
Re: Refresh/Repopulate Listview after Updating.
Quote:
Originally Posted by maps
So this can also be done for datagrids or datagridviews!
Yes I am sure it can, however I don't really use those controls ever. Most of my projects warrant the use of a listview over any sort of data bound grid control.
-
Re: Refresh/Repopulate Listview after Updating.
I also wonder, how would some one, declare the LVI if he wants to just insert Data.
I am thinking that it would take the same routine.
****EDITS********
In the case of a ListView not datagridview.
-
Re: Refresh/Repopulate Listview after Updating.
grr moved it to 2003 am getting error at 1 line "F = New frmUpdate"
I know this is your question MAPS so excuse the my side point!!
cheers George
-
Re: Refresh/Repopulate Listview after Updating.
Quote:
Originally Posted by maps
I also wonder, how would some one, declare the LVI if he wants to just insert Data.
I am thinking that it would take the same routine.
****EDITS********
In the case of a ListView not datagridview.
In that cause you would simply add a new listviewitem to the listview, with the data, instead of updating an existing one...
-
Re: Refresh/Repopulate Listview after Updating.
Whats the message in the error?, is your insert/update form called frmUpdate?
-
Re: Refresh/Repopulate Listview after Updating.
Quote:
Originally Posted by Ggalla1779
grr moved it to 2003 am getting error at 1 line "F = New frmUpdate"
I know this is your question MAPS so excuse the my side point!!
cheers George
I'll move the code to a 2003 project and post that as well
-
Re: Refresh/Repopulate Listview after Updating.
Right thats it Klienma. I will give that a go.
Thanks for the time you put into it.
-
Re: Refresh/Repopulate Listview after Updating.
many thanks Kleinma...its realy just that 1 line that was offending
-
Re: Refresh/Repopulate Listview after Updating.
Just out of curiosity, why do u opt for listviews from datagrids
-
2 Attachment(s)
Re: Refresh/Repopulate Listview after Updating.
Here you go. there is both a 2003 and 2005 version.
I also added the ability to "Add New" instead of just update.
-
Re: Refresh/Repopulate Listview after Updating.
Quote:
Originally Posted by maps
Just out of curiosity, why do u opt for listviews from datagrids
I feel they have more control, and I like to keep my data layer seperate from my GUI layer.
Also since it is a standard windows control, users are generally very familiar with how the listview operates...
its a little bit of preference too though.
-
Re: Refresh/Repopulate Listview after Updating.
Many thanks for the 2003 version, I hadnt passed LVI to update form...ho hum!!!
I am a bit confused how the Update form closes with line
Me.DialogResult = Windows.Forms.DialogResult.OK
I get the byref bit and its cool and fast that the whole listview doesnt have to be updated...thats great!!!
-
Re: Refresh/Repopulate Listview after Updating.
Quote:
Originally Posted by Ggalla1779
Me.DialogResult = Windows.Forms.DialogResult.OK
When you set the forms dialog result, it hides the form
Quote:
from MSDN
The Close method is not automatically called when the user clicks the Close button of a dialog box or sets the value of the DialogResult property. Instead, the form is hidden and can be shown again without creating a new instance of the dialog box. Because of this behavior, you must call the Dispose method of the form when the form is no longer needed by your application.
you will notice i dispose of the form in the Finally part of the try/catch block.
-
Re: [RESOLVED] Refresh/Repopulate Listview after Updating.
clever....thanks for your help today that was interesting cheers George
-
Re: [RESOLVED] Refresh/Repopulate Listview after Updating.
Don't forget of course, that the examples provide no error handling or data validation, and you would no doubt want that in a real world application.
-
Re: [RESOLVED] Refresh/Repopulate Listview after Updating.
-
Re: [RESOLVED] Refresh/Repopulate Listview after Updating.
Back Again.
I am using Edit(method2) in your last example. I would like to call up a message, if one tries to type in a name that duplicates the other Names in the Listbox.
If One Leaves or types in the Orignal Name he is trying to Edit, then bingo...no message pops up.
How can i achieve this?