Printing / Saving listview
Printing / Saving listview
Printing / Saving listview
Printing / Saving listview
Printing / Saving listview
Printing / Saving listview Printing / Saving listview Printing / Saving listview Printing / Saving listview Printing / Saving listview Printing / Saving listview Printing / Saving listview Printing / Saving listview
Printing / Saving listview Printing / Saving listview
Printing / Saving listview
Go Back  Xtreme Visual Basic Talk > > > Printing / Saving listview


Reply
 
Thread Tools Display Modes
  #1  
Old 10-20-2014, 11:53 AM
Hexion Hexion is offline
Newcomer
 
Join Date: Oct 2014
Posts: 6
Default Printing / Saving listview


I have this current code for saving a ListBox to a file....

Public Sub logfile()
Dim FILE_NAME As String = "F:\NEwFolder\FileLog.txt"

Dim cnt As Integer

Dim objwriter As New System.IO.StreamWriter(FILE_NAME, True)

Do While cnt < ListBox1.Items.Count

objwriter.WriteLine(ListBox1.Items(cnt), New Font("Time New Roman", 30), Brushes.Black, 200, 200 + (cnt * 32))

cnt = cnt + 1
Loop

objwriter.Close()

End Sub


I have swapped the listbox for a listview, How can I adapt this code to work for the listview?

Thanks for any Help
Reply With Quote
  #2  
Old 10-20-2014, 02:20 PM
PlausiblyDamp's Avatar
PlausiblyDampPrinting / Saving listview PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

How are you populating the list view in the first place? If you have the data to populate the list view couldn't you use this to write to the file?

Also why did you scroll past the VB.Net sections to the VB 4,5 and 6 section to post this when you are using VB.Net?
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #3  
Old 10-21-2014, 10:38 AM
Hexion Hexion is offline
Newcomer
 
Join Date: Oct 2014
Posts: 6
Default

The info coming from a Database, the project is a till/cash register so the list will have items added to it and removed before a final copy is needed to be saved, I was using a listbox and it worked fine saving the list to a text file and printing, but I had a problem with alignment with the items on the left and prices on the right, the listview solved that but now I don't know how to save or print it, only been doing this for a few week so a total novice


As for where I posted it, I came to the forum via google and just see 'General' totally overlooked the sub categories, Sorry!
Reply With Quote
  #4  
Old 10-22-2014, 04:46 AM
PlausiblyDamp's Avatar
PlausiblyDampPrinting / Saving listview PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

How does the user add or remove items from the ListView? What code is being used to manipulate the contents?

It might be easier to keep track of the changes in a separate data structure e.g. an array or list and use this as the source for your printing.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #5  
Old 10-24-2014, 01:26 AM
Hexion Hexion is offline
Newcomer
 
Join Date: Oct 2014
Posts: 6
Default

I have this code for the database


Private Sub AddDrink(ByVal DrinkType As String)
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
Dim dbProvider As String
Dim MyDrinkPrice As String

dbProvider = "provider=Microsoft.ACE.OLEDB.12.0; Data Source = \Soft Tech Project\DrinkDB.accdb"

con.ConnectionString = dbProvider

con.Open()
sql = "SELECT DrinkPrice FROM Drinks WHERE DrinkName = " & "'" & DrinkType & "'"
da = New OleDb.OleDbDataAdapter(sql, con)

con.Close()
ds.Reset()

da.Fill(ds, "TempPrice")

MyDrinkPrice = Format(ds.Tables("TempPrice").Rows(0).Item(0), "£0.00")

LstItems.Items.Add(DrinkType & Chr(9) & &Chr(9) & MyDrinkPrice)

SubTotal = SubTotal + MyDrinkPrice
lblSubtotal.Text = Format(SubTotal, "£0.00")

End Sub


And then I have button the user can click to add an item to the list box and all that is....

AddDrink("Carling")
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Printing / Saving listview
Printing / Saving listview
Printing / Saving listview Printing / Saving listview
Printing / Saving listview
Printing / Saving listview
Printing / Saving listview Printing / Saving listview Printing / Saving listview Printing / Saving listview Printing / Saving listview Printing / Saving listview Printing / Saving listview
Printing / Saving listview
Printing / Saving listview
 
Printing / Saving listview
Printing / Saving listview
 
-->