5 Replies - 5816 Views - Last Post: 13 July 2012 - 06:30 AM Rate Topic: -----

#1 stringy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 11-July 12

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!

  ' 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




Is This A Good Question/Topic? 0
  • +

Replies To: Problem with print/column spacing in a loop with listviewbox subitems

#2 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 840
  • Joined: 21-December 11

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

Was This Post Helpful? 0
  • +
  • -

#3 stringy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 11-July 12

Re: Problem with print/column spacing in a loop with listviewbox subitems

Posted 12 July 2012 - 01:41 PM

View Postsela007, 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


View Poststringy, on 12 July 2012 - 01:39 PM, said:

View Postsela007, 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

No go I'm afraid .index is not a member of listviewsub item
Any other ideas ? Please
Was This Post Helpful? 0
  • +
  • -

#4 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 840
  • Joined: 21-December 11

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

Was This Post Helpful? 1
  • +
  • -

#5 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

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?
Was This Post Helpful? 0
  • +
  • -

#6 stringy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 11-July 12

Re: Problem with print/column spacing in a loop with listviewbox subitems

Posted 13 July 2012 - 06:30 AM

View Postsela007, on 12 July 2012 - 01:53 PM, said:

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



Great that sorted it - the logic kicked in with your 1st post when I thought about it
Thank you
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1