jimmy89 0 Report post Posted August 19, 2007 Hi All,These are the steps in which the program worksLoad Data into text box > Line by Line copy the data into list boxes > Load data into separate form from text boxes.What I am having problems with is when I want to edit the data that is on the other form. Each different value has a text box and what I am trying to do is to update the original text box so that I can save the file onto the computer. But because the original text box already contains the data, I cannot just add new lines to the end of the text box, because I would then have two entries.What I'm looking for is a way of updating the lines in the text box. Or, if I move the new data back into the list boxes, what Is the easiest way to move data from the list boxes to a text box.Thanks,-jimmy Share this post Link to post Share on other sites
faulty.lee 0 Report post Posted August 19, 2007 Don't quite get what you want.Normally I would have a list box on the left, then a few textbox on the right side to display detail info. Then I bind the SelectedIndexChanged event, and then check the list box SelectedItem count, make sure it's one(It can be zero). If it's one, then display the detail of the selected item on the right hand side (either with SelectedItems(0).Text OR query from database, I usually store the ID in the "Tag" of the listbox item), at the same time enable the "Save" button. If it's not one, then clear all the text box, and make the "Save" button disabled.Hope this can help you a bit Share this post Link to post Share on other sites
jimmy89 0 Report post Posted August 20, 2007 I'll try and explain it a bit more. The external file has list of items, of which there are 13 details for each item. So the file reads 1,2,3..13 then starts at 1 again for the next item. When the program reads the file, it puts each of the details in its own list box (so there are 13 list boxes). So in one list box, I will have all the one detail for all the items, and so on for all the other items. When you type in the ID number for a item (the ID is the first detail) the first list box will find the ID number and select it. Using the SelectedIndex, all the other list boxes will select the detail for each item. Then the details from each of the list boxes are displayed in text boxes and labels, so they are nicely formatted for the end user. Now the end user can change the text in the text boxes and this is what I want to save. What would be the easiest way of saving the 'new' (or updated) details for the item back into the external file? Thanks, -jimmy Share this post Link to post Share on other sites
iGuest 3 Report post Posted August 20, 2007 use $_POST to collect the variables from the text box, then use fopen() to edit the file. If you're havig trouble checking what the ID of the item is, then add <input type="hidden" name="id" value="[iD Here]"> at the start of the text boxes, and you can retrieve it from $_POST["id"]. Hope that answers your question! Share this post Link to post Share on other sites
jimmy89 0 Report post Posted August 20, 2007 Sorry, but I;m programming it in VB.NET, not PHP! I should have mentioned it, but being in the VB Forum. Share this post Link to post Share on other sites
faulty.lee 0 Report post Posted August 21, 2007 I'll try and explain it a bit more. The external file has list of items, of which there are 13 details for each item. So the file reads 1,2,3..13 then starts at 1 again for the next item. When the program reads the file, it puts each of the details in its own list box (so there are 13 list boxes). So in one list box, I will have all the one detail for all the items, and so on for all the other items. When you type in the ID number for a item (the ID is the first detail) the first list box will find the ID number and select it. Using the SelectedIndex, all the other list boxes will select the detail for each item. Then the details from each of the list boxes are displayed in text boxes and labels, so they are nicely formatted for the end user. Now the end user can change the text in the text boxes and this is what I want to save. What would be the easiest way of saving the 'new' (or updated) details for the item back into the external file? Thanks, -jimmy Now i get you. Sorry for the late reply, I was traveling back to my home town. OK, you idea seems a bit confusing to the user, IMHO. I would recommend you using a listview, and have 13 column. So when the user selected that particular row, you then enable an edit button. The user can either click Edit or double click, which will then bring up a dialog box with the 13 details particular to that ID. Then you can do saving from there, it's quite straight forward after that. If the user decided to cancel the changes, you just need to close the dialog box. Optionally you can set DialogResult to Cancel. For successful save, you can return OK, so that your main form can refresh the listview. The reason i recommend this is that, your method, it's hard for user to decide on canceling and saving, you can select a ID, then edit the text box, then select a diff one, you then need to intervene if the user would like to discard the changes or not. So you need to trap quite a lot event to handle the user friendliness. It become tedious if the user was prompt all the time even though he just want to discard the changes. It might happen that he didn't change anything, and also being prompt, unless you trap all the text box with the OnChange event to take note of the changes. The dialog box, to cancel, the user just need to press Esc, or click cancel, it's quite a standard feature. With a dialog box, you also narrow down the problem and bugs, and give the user a focus job. Share this post Link to post Share on other sites
iGuest 3 Report post Posted August 21, 2007 Sorry, but I;m programming it in VB.NET, not PHP! I should have mentioned it, but being in the VB Forum.Sorry! *goes all embarrassed* My bad, but the principle should generally be the same, I think Share this post Link to post Share on other sites
jimmy89 0 Report post Posted August 21, 2007 (edited) Habble, I done it before too! I think the idea is the same though!ok, that make sense so far. How is the easiest way to make the list box with 13 columns? in coding terms of cause. What code would I need to pull the information from the text box (or the external file) and format it in the columns?Please correct me If im wrong, but when the dialog appears it takes the selected information (of the item thats being edited) and displays it for editing. Then, when the changes are accepted (OK button pressed) it copies the information back into the listbox.Then, how can I save this listbox? Is there a simple way of reading all the lines and then saving them into a file?Thanks Heaps,-jimmy Edited August 21, 2007 by Jimmy89 (see edit history) Share this post Link to post Share on other sites
faulty.lee 0 Report post Posted August 22, 2007 ok, that make sense so far. How is the easiest way to make the list box with 13 columns? in coding terms of cause. What code would I need to pull the information from the text box (or the external file) and format it in the columns? listview.Items.Add(New ListViewItem(New String() {"column1", "column2", "column3"})) It's better to use ListView, use Details mode for View's property. You need to configure the columns manually, so after inserting, it will goes according to what column you have configured.Then, how can I save this listbox? Is there a simple way of reading all the lines and then saving them into a file?You don't actually save the listbox, when the user press OK, it's save right away. Then the listbox is refresh the display the latest data.If you need to keep the all the data temporarily, but not saving it all the time, then write a class or use collection to keep the data, any changes should be applied there, then save only when at the point where you want it to.(Save All) Share this post Link to post Share on other sites
jimmy89 0 Report post Posted August 23, 2007 You don't actually save the listbox, when the user press OK, it's save right away.I don't quite understand what you mean, when the values in the 'detail' view are changed and the OK button is press, how do I save those values into the text file I have already, but not making a second entry under the same ID (so appending the data thats there already) Share this post Link to post Share on other sites
faulty.lee 0 Report post Posted August 23, 2007 I don't quite understand what you mean, when the values in the 'detail' view are changed and the OK button is press, how do I save those values into the text file I have already, but not making a second entry under the same ID (so appending the data thats there already)In that case, you'll need to have a way to store the data in memory, in a structure or class, or even a datatable would do, then from there you write function to do the loading and saving of data. Then it become independent of the way you want to manipulate it. You can always save back to the same text file, overwritting all the data. Since you have loaded everything into memory, so you won't have duplicate ID. Share this post Link to post Share on other sites
jimmy89 0 Report post Posted August 24, 2007 thanks for that! I will try what you have suggested so far and get back to you with any problems, if you don't mind Share this post Link to post Share on other sites
iGuest 3 Report post Posted May 4, 2009 display ms word data in to gridview or througha link in gridviewUpdating Values In A Text BoxSir, I m developing a intranet site in which I have a ms access data base in which I have a column that contains ms word ,I want to display that ms word data in to grid view (or hyperlink in grid view) so that when user click it then it would be display in ms word format and if any one want to make some correction then that updated data should be saved in database.. from john michal -reply by john Share this post Link to post Share on other sites
iGuest 3 Report post Posted July 4, 2009 help,,Updating Values In A Text BoxI have recently completed my short course inVB. Anyone help me where to learn more about vb programming as in the short course they haven't taught me everything,,, -reply by qahar Share this post Link to post Share on other sites
iGuest 3 Report post Posted November 24, 2009 I have inserted into the database on edit I am showing all the details into the respective text boxes but cant change the values can u help me Please ..I no the update query but when m displayin the content using the syntax= va lue="sometin" the values shud change on changing the values-reply by amol Share this post Link to post Share on other sites