Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer
This is the forum to discuss the Wrox book Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer by Rod Stephens; ISBN: 9780470596906
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 19th, 2012, 08:39 PM
Registered User
Points: 42, Level: 1
Points: 42, Level: 1 Points: 42, Level: 1 Points: 42, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2011
Posts: 9
Thanks: 5
Thanked 0 Times in 0 Posts
Question Read Write

Hi Rod

Can I use the Read/Write command while working with List view

I can get the textBox to work, it keeps the last value there from when i shut it down but the list items ie Pencil cost and all that seems to get lost

i use textBox1.Text = valueReader.ReadLine();
valueReader.Close();

and valueWriter.WriteLine(textBox1.Text);
valueWriter.Close();
for the textBox

and
itemColumn.Text = valueReader.ReadLine();

valueWriter.WriteLine(itemColumn.Text);

and so on

when it comes to doing the same with the list view Im a little stuffed
Ive tried a few things but cant seem to get it to work
I'm actually expanding on your Lesson 13 (understanding scope) trying to apply the read write to it

any ideas where im going wrong
Cheers Harold
  #2 (permalink)  
Old March 20th, 2012, 09:44 AM
Rod Stephens's Avatar
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Hi Harold,

Where are you doing the WriteLine statements? They should probably all be in the form's Closing event handler so they all come together.

If you're writing the values into a text file (I suspect you are), then you can open the file in WordPad or NotePad to see what's in there and determine whether the writing part is working.

Then the reading should all be in the form's Load event handler.

What are you trying to save for the ListView? The currently selected item? If so, I would write and read the values in the SelectedIndices collection. They're numbers so you might need to read them as strings and then use CInt to convert them into integers before using them.

Let me know what you're trying to do with the ListView and I'll try to provide more detail if you need it.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
  #3 (permalink)  
Old March 20th, 2012, 08:02 PM
Registered User
Points: 42, Level: 1
Points: 42, Level: 1 Points: 42, Level: 1 Points: 42, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2011
Posts: 9
Thanks: 5
Thanked 0 Times in 0 Posts
Default R/W

Yes I have set it up the same as in your read write tutorial
I have the read in a load handler and the write in the closing handler

I have put these ahead of the body of the code . the text box is working but the items in the list view dont show up after I close and open the program


Using your example in the scope tutorial im trying to have the program load with the items i have put in from the add item button when I shut it down so when i open it back up again the Items will be there as I left it and be able to add more input to do the same
Im only doing this so I can marry each piece I learn into another program so I can understand what is happening and that I understand how it works as I learn quicker by trying things out
Also Im thinking I could put together a small program using this to track the servicing of my Vehicles later on

Cheers Harold
  #4 (permalink)  
Old March 21st, 2012, 09:40 AM
Rod Stephens's Avatar
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

that sounds like a reasonable approach.

Probably the best thing would be for you to zip up the project and email it to me at RodStephens@CSharpHelper.com. Then I can see exactly what's going on.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Direct I/O read/write pakman VB.NET 2002/2003 Basics 1 September 13th, 2006 03:27 PM
read & write file C# minhpx General .NET 1 February 21st, 2005 04:14 PM
How Can I Read or Write to Parallel Port? qdata Visual C++ 3 January 31st, 2005 07:47 AM
magnetic stripe read/write frankv25 Pro VB.NET 2002/2003 1 April 16th, 2004 03:44 PM
How to read/write Access Database jmmendes Access VBA 0 November 18th, 2003 01:26 PM



All times are GMT -4. The time now is 04:57 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.