problems editing dataGrid and 'Tab' delimited text file

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2007
Posts: 52
Reputation: reaven is an unknown quantity at this point 
Solved Threads: 0
reaven reaven is offline Offline
Junior Poster in Training

problems editing dataGrid and 'Tab' delimited text file

 
0
  #1
Aug 25th, 2008
  1. StreamReader reader = File.OpenText("mystations.txt");
  2. string line = reader.ReadLine();
  3. while (line != null)
  4. {
  5.  
  6.  
  7.  
  8. // string[] stationtxt = line.Split('\t');
  9.  
  10. string name = line.Split('\t')[0];
  11. string url = line.Split('\t')[1];
  12. string desc = line.Split('\t')[2];
  13. Image img = Image.FromFile("c:/pictures/"+ name + ".jpg");
  14. line = reader.ReadLine();
  15. dgLogo.Image = new Bitmap(img);
  16. dataGridView1.Rows.Add(name, url, desc, img); //(stationtxt);
  17.  
  18. }
  19. reader.Close();
  20. reader.Dispose();

I'am able to edit the values in the datagrid but when i reload the form it display the original values of course.

i want to catch the edited values and save it again to the tab delimited text file.
and also be able to delete a row from the text file and datagrid.
the image column is there just for display its not editable.

if someone can provide me a sample or point me in the right direction
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: problems editing dataGrid and 'Tab' delimited text file

 
0
  #2
Aug 25th, 2008
If you split your data into a list of array of string, you can do a bit of googling and find how to use a list as a data source, then when they finish, just tab join the data back and write it out.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 52
Reputation: reaven is an unknown quantity at this point 
Solved Threads: 0
reaven reaven is offline Offline
Junior Poster in Training

Re: problems editing dataGrid and 'Tab' delimited text file

 
0
  #3
Aug 25th, 2008
believe me a read a lot of guides and the worst are from msft msdn website there samples never works.

i have the logic in my head. the problem is converting that to code, in where event to add it. datagrid have a lot lot of events,
for example i have to added to oncellchange event, onclick event, on edit event.

all codes have very different methods and it get confusing.

-thanks BTW, I think you reply to my other post, right?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: problems editing dataGrid and 'Tab' delimited text file

 
0
  #4
Aug 25th, 2008
I had this working fairly quickly when I tried it, I dont have the machine to hand I did it on, but I took a csv file and chucked it into a list of array of string and then added it.

As for your other post - which one?
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 52
Reputation: reaven is an unknown quantity at this point 
Solved Threads: 0
reaven reaven is offline Offline
Junior Poster in Training

Re: problems editing dataGrid and 'Tab' delimited text file

 
0
  #5
Aug 25th, 2008
As for your other post - which one?
the one i have problem lunch a batch file from the code.

I took a csv file and chucked it into a list of array of string and then added it.
ok the problem is how to get the new edit values from the datagrid i cant use the Arraylist because of the image column in the datagrid with the array i dont find how the get the images show up i end up doing in it like the code i show in the other post.

so my doubt is not how to add the text file to the datagrid I did that already. is how to get the new edited values once the user edit them directly in the datagrid. then get all the values from the datagrid and save them back to the 'tab' delimited text file.
Last edited by reaven; Aug 25th, 2008 at 4:33 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: problems editing dataGrid and 'Tab' delimited text file

 
0
  #6
Aug 25th, 2008
You dont, or rather you shouldnt need to it should all be done for you..

See http://msdn.microsoft.com/en-us/libr...tychanged.aspx
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 52
Reputation: reaven is an unknown quantity at this point 
Solved Threads: 0
reaven reaven is offline Offline
Junior Poster in Training

Re: problems editing dataGrid and 'Tab' delimited text file

 
0
  #7
Aug 26th, 2008
Originally Posted by LizR View Post
You dont, or rather you shouldn't need to it should all be done for you..
remember am not using any database or dataset. I know this is automatically if you are connect to a database.

i am reading from a text file and passing that values to the datagrid for easy viewing and (possible and hope so) easy editing.

or do you mean this could be done even if i am not using a database?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: problems editing dataGrid and 'Tab' delimited text file

 
0
  #8
Aug 26th, 2008
You didnt read the link I posted then, as thats exactly what that does. You can use lists as data sources.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 52
Reputation: reaven is an unknown quantity at this point 
Solved Threads: 0
reaven reaven is offline Offline
Junior Poster in Training

Re: problems editing dataGrid and 'Tab' delimited text file

 
0
  #9
Aug 26th, 2008
I know I read it but if you see my code I fill the datagrid individually because of the image column if I use the list how I fill the images column because my textfile only contain the name of the image file, the image is in another folder and the datagrid column is a DataGridViewImageColumn.

i was trying the code from the page you post when i encounter the problem of the image.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: problems editing dataGrid and 'Tab' delimited text file

 
0
  #10
Aug 26th, 2008
You should be able to make an image part of the row.. without any major issues.. Then it would update properly
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC