Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can i produce a report from a listview?

Status
Not open for further replies.

eli13

Programmer
Jan 20, 2010
18
PH
Hello,
How can I produce a report from a listview with a checkbox?
i have my database and the table tbl_papers where trans are stored.
Now, In VB I created a listview with checkbox, and I want that i you check reports in the listview you can print them out using crystal report or datareport.

Help needed here.
Thanks
 
Sure scroll through selected items then print via whatever method you choose. For example-

For X = 1 To lstMyList.ListItems.Count
If lstMyList.ListItems(X).Checked = True Then
Printer.Print lstMyList.ListItems(X).ListSubItems(YourPosition).text
End If
Next X

Search for printer.print for the rest. Personally I love Crystal.

Tom
 
Sorry,
I thought you said "without" not "out" with Crystal or datareport. To print out of crystal you will need to update the data with some sort of flag/boolean in the database then load the report accordingly; still using similiar code I suggested. I think you're question is too vague at the moment, for anyone to want to give a complete solution.

Tom
 
Tom, i want to use the code you gave but i can't figure out how to show all of the record per row, its like that the code only prints one (x,y) position and not the entire row of the checked item.

just asking,
thanks
 
Hello,

I'm not sure if you can select an entire row. Besides, the formating would not be even between fields. Anyway you could do something like -

Printer.Print lstMyList.ListItems(X).ListSubItems(YourPosition).text & " " & lstMyList.ListItems(X).ListSubItems(YourNEXTPosition).text & ...


How are you handling the printing? Did you do printer.print or were you wanting to use Crystal or data report?

If using printer.print - This example just puts a space between them which probably isn't the formating you want either. You would want to space them into a more easily viewed format such as reading the length of the first field the adding the appropriate spaces to look like -

Apple Red 4
Pear Green 5

instead of

Apple Red 4
Pear Green 5

which is hard to read.

If using Crystal or data report - Another approach would be to have a column "ID" with 0 width. Then scroll through items to see if checked then build your SQL statment based on the "ID"'s. Or as I originally said set a flag/boolean. In which you would just want the ID or some unique field to update the data. In neither of these approaches, would you want the entire row at once.

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top