Updating Listbox Items
-
Hi Yallz, I have a list box that you can edit the items in (click a button, and it pops up a form so you enter the info you want), the problem I'm encoutering is that once the user presses OK on the edit form the listbox isn't update with the new informatin. Is there anyway to update a listbox item without removing it and then adding it back? Thanks! - monrobot13
-
Hi Yallz, I have a list box that you can edit the items in (click a button, and it pops up a form so you enter the info you want), the problem I'm encoutering is that once the user presses OK on the edit form the listbox isn't update with the new informatin. Is there anyway to update a listbox item without removing it and then adding it back? Thanks! - monrobot13
Are you doing something like this in your click event: MyForm f = new MyForm(); f.Show(); If you are then your problem is you are getting a NEW form each time with an empty list. Try hiding the listbox form when you are done with it. In the button click event unhide it.
-
Are you doing something like this in your click event: MyForm f = new MyForm(); f.Show(); If you are then your problem is you are getting a NEW form each time with an empty list. Try hiding the listbox form when you are done with it. In the button click event unhide it.
That's not it. I actually serialize all the listbox items when the form is closed and then deserialize them when it's loaded. When I do this it does show the new information. When you add an item to a listbox it call's it ToString function to get the text to display. I want to update the text that is being displayed without removing and readding the item. - monrobot13
-
That's not it. I actually serialize all the listbox items when the form is closed and then deserialize them when it's loaded. When I do this it does show the new information. When you add an item to a listbox it call's it ToString function to get the text to display. I want to update the text that is being displayed without removing and readding the item. - monrobot13
Don't use ToString(). Add the item itself, or better yet use databinding to display a complete collection. When you edit the collection entry, the listbox is updated (possibly after a call to Refresh()).
-
Hi Yallz, I have a list box that you can edit the items in (click a button, and it pops up a form so you enter the info you want), the problem I'm encoutering is that once the user presses OK on the edit form the listbox isn't update with the new informatin. Is there anyway to update a listbox item without removing it and then adding it back? Thanks! - monrobot13
hi, i encountered a similar problem some time back. I do not have the code with me right now, but i hope that i can put the solution down in words. 1: create a custom 'event' class that gets/sets a string. This is the string that the user will be updating when he uses the new form (by using 'set' property). 2: try to 'fire' events when the user is done with the edit box. (I am assuming that both the edit window and the main window are on same thread, else you will have to call an invoke on the form). 3: send the string as an argument to the main Form. 4: define an event handler on the main form that will handle your custom events. This will retrieve the string using the 'get' property. i'll try and post the code if i can. hope this helps. regards, Mithun.