473,405 Members | 2,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How Do I Write ListView items to a text file?

Hello,

I'm having trouble writing the contents of a ListView Control, one line at a time, to a text file.

I am able to write the lines of a ListBox Control to a text file using the code below, but the same will not work for a ListView control even if there are no subitems.

In my application I must use the ListView control because I must have several columns.


Can anyone help me with this?





Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Class Form1
  3.  
  4.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  5.  
  6.         Dim objFile As New System.IO.StreamWriter("C:\Test.txt")
  7.         Dim intcounter As Long = ListBox1.Items.Count
  8.         For intcounter = 0 To ListBox1.Items.Count - 1
  9.             objFile.WriteLine(Listbox1.Items(intcounter).ToString)
  10.         Next intcounter
  11.         objFile.Close()
  12.     End Sub
  13. End Class
  14.  
  15.  
Jan 5 '13 #1
1 3254
Rabbit
12,516 Expert Mod 8TB
With listview controls, you can use the GetItemAt(x,y) method to get the data from a certain row and column.
Jan 7 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tino | last post by:
Hi, Is it possible to have a php script that creates a text file on it's host server... something like a print to file or write to file? What I want to do is have a php script that creates a...
3
by: burdeen | last post by:
I can't find any way of writing a unicode, or UTF-8 format text file. Right now i have a Unicode string that i write to the text file and the unicode characters are replaced with ANSI question...
3
by: NewToPHP | last post by:
I am COMPLETELY NEW TO PHP San someone supply me with a PHP script to read and write to a text file on the server Also any suggestion on a free PHP editor?
7
by: nonpareil | last post by:
I'd like to know if an HTML form page can be made to output to a text file on the same computer. The references that I've consulted only discuss the GET and POST actions communicating with the...
14
by: Niron kag | last post by:
Hello ! With c# , I want to write to a text file in a specific font and color. Any ideas ? Thanks...
2
by: Quentin | last post by:
Any code on how to start write to a new file would be appreciated. In the example below: How would I start the write to a file on the word "Recipe" and then write every line beneath it until "End...
6
Atran
by: Atran | last post by:
Hello: In this article: You will learn to Write or Read A Text File. Let's Begin: First Create a new project (ConsoleApp or WinApp). And Make sure your program uses these namespaces: using...
4
by: someone28485 | last post by:
hi,i need 2 write code in C#.Net to read a text file with text as 22.13 21.65 25.16 31.22 and so on, i need 2 read this text and then take mean of the 4 values and write that mean result in...
4
by: mvvdsteen | last post by:
Hello all, I'm quite new to c++. I made a small program that will help me analyse wind tunnel data. But now I want this program to write to a text file. This works just fine, except it discards...
4
by: Keith G Hicks | last post by:
I'm trying to read a text file and alter the contents of specific lines in the file. I know how to use streamreader to read each line of a file. I'm doing that already to get the data into a...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.