' Loop through our listview items
For Each lvwItem In ListViewrep.Items
columns = 50 ' gives left hand Margin
For Each lvwSubItem In lvwItem.SubItems
canvas.DrawString(lvwSubItem.Text, f, Brushes.Black, columns, lines)
columns += 90 ' this needs to some how vary for each column
Next
canvas.DrawString(lvwItem.Text, f, Brushes.Black, 50, lines)
' Increment the count (for display purposes)
lines += 8
Next
5 Replies - 1767 Views - Last Post: 13 July 2012 - 06:30 AM
#1
Problem with print/column spacing in a loop with listviewbox subitems
Posted 11 July 2012 - 04:33 AM
Hi guys, I have a problem which has got me stummped. I need to print the contents of a listview box with 6 columns and 'x' rows. The code works fine but prints the columns with the same spacing (columns +=90) I need different spacing for each column i.e / item 1 50pts / item 2 120pts / item 3 50pts/ item 4 300 pts / etc. I have tried looping through the subitems using all ways but just can't fathom this - HELP!
Replies To: Problem with print/column spacing in a loop with listviewbox subitems
#2
Re: Problem with print/column spacing in a loop with listviewbox subitems
Posted 11 July 2012 - 06:01 PM
you can set column width depending on current column(SubItem) in lvwItem.SubItems
For Each lvwSubItem In lvwItem.SubItems 'if lvwSubItem.index = 0 then column = ... 'if lvwSubItem.index = 1 then column = .. '... Next
#3
Re: Problem with print/column spacing in a loop with listviewbox subitems
Posted 12 July 2012 - 01:41 PM
sela007, on 11 July 2012 - 06:01 PM, said:
you can set column width depending on current column(SubItem) in lvwItem.SubItems
For Each lvwSubItem In lvwItem.SubItems 'if lvwSubItem.index = 0 then column = ... 'if lvwSubItem.index = 1 then column = .. '... Next
stringy, on 12 July 2012 - 01:39 PM, said:
No go I'm afraid .index is not a member of listviewsub item
Any other ideas ? Please
#4
Re: Problem with print/column spacing in a loop with listviewbox subitems
Posted 12 July 2012 - 01:53 PM
then you can use same logic with for/next loop.
For i As Integer = 0 to lvwItem.SubItems.Count - 1 'if i = 0 then columns = ... 'if i = 1 then columns = .. Next
This post has been edited by sela007: 12 July 2012 - 01:53 PM
#5
Re: Problem with print/column spacing in a loop with listviewbox subitems
Posted 12 July 2012 - 03:04 PM
I don't suppose ListViewItem.Position would help?
#6
Re: Problem with print/column spacing in a loop with listviewbox subitems
Posted 13 July 2012 - 06:30 AM
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|