2 Replies - 5784 Views - Last Post: 28 June 2010 - 03:26 PM Rate Topic: -----

#1 Dummy1912  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 04-February 10

[vb2008] Listview Print?

Posted 28 June 2010 - 07:58 AM

Hello guys,

i have a really bad problem with the print function for the listview.
i have search on the net for a few days already but
no success.

i have even try with a drawimage but thats not working.

i like to print my lixtview with the icons in it.
but i get only the text :(

here is my listview code where i load my records:

            LstView.View = View.Details
            LstView.SmallImageList = ImgIcons
            Dim lSingleItem As ListViewItem

            RsBill.Open("select * from customers Order by id ASC", ConBill)
            If RsBill.RecordCount > 0 Then
                LstView.BeginUpdate()
                RsBill.MoveFirst()
                For i = 0 To RsBill.RecordCount - 1
                    If RsBill.Fields!aopen.Value = True Then
                        lSingleItem = LstView.Items.Add(RsBill.Fields!id.Value, 0) 'open icon
                    ElseIf RsBill.Fields!aclosed.Value = True Then
                        lSingleItem = LstView.Items.Add(RsBill.Fields!id.Value, 1)  'closed icon
                    End If




here you see that i load the icons from a imagelist
and when the record is true i get the first icon
if false the second one.

then here is the print function:

        'Title    
        Dim headfont, headfont2 As Font
        Dim X1 As Integer
        Dim Y As Integer
                headfont = New Font(FntFC2.Families(0), 22, FontStyle.Bold, GraphicsUnit.Point)
        headfont2 = New Font("Courier New", 10, FontStyle.Bold)
        X1 = PrintDocument1.DefaultPageSettings.Margins.Left

       
        e.Graphics.DrawString("Bill Payment's System [ Accounts ] - " & Date.Today.Year, headfont, Brushes.DarkRed, X1 + 250, Y + 40)
        With PrintDocument1.DefaultPageSettings

            e.Graphics.DrawLine(Pens.Black, 0, Y + 70, e.PageBounds.Width, Y + 70)
        End With

        'Headings    
        currentY = 100
        For Each c In LstView.Columns
            maxY = Math.Max(maxY, g.MeasureString(c.Text, f, c.Width).Height)
            colLefts(idx) = l
            colWidths(idx) = c.Width
            lr = New RectangleF(colLefts(idx), currentY, colWidths(idx), maxY)
            
            If lr.Width > 0 Then g.DrawString(c.Text, f, b, lr)
            l += c.Width
            idx += 1
        Next
        currentY += maxY + gap
        g.DrawLine(Pens.Black, 0, currentY, e.PageBounds.Width, currentY)
        currentY += gap
        'Rows    
        iCount = LstView.Items.Count - 1
        For ii = CurrRow To iCount
            If (currentY + maxY + maxY) > e.PageBounds.Height Then
                CurrRow = ii - 1
                e.HasMorePages = True

                currentY += maxY + gap
                Exit For

            End If

            l = 0
            maxY = 0
            idx = 0
            For Each lvsi In LstView.Items(ii).SubItems
                maxY = Math.Max(maxY, g.MeasureString(lvsi.Text, f, colWidths(idx)).Height)
                lr = New RectangleF(colLefts(idx), currentY, colWidths(idx), maxY)
                If lr.Width > 0 Then g.DrawString(lvsi.Text, f, b, lr)
                idx += 1
            Next
            currentY += maxY + gap
        Next



and i have add a attach file in here :)

please can anyone help me im stuck :(
and its make me a little jumpy the last few weeks because i can't find it.

thanks

Dummy1912

Attached image(s)

  • Attached Image

This post has been edited by Dummy1912: 28 June 2010 - 07:59 AM


Is This A Good Question/Topic? 0
  • +

Replies To: [vb2008] Listview Print?

#2 Luc001  Icon User is offline

  • D.I.C Addict

Reputation: 84
  • View blog
  • Posts: 617
  • Joined: 04-May 09

Re: [vb2008] Listview Print?

Posted 28 June 2010 - 01:46 PM

Hi,

Perhaps you can find some answers, here.
Was This Post Helpful? 0
  • +
  • -

#3 Dummy1912  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 04-February 10

Re: [vb2008] Listview Print?

Posted 28 June 2010 - 03:26 PM

Hello Luc,

i know i have read it first before i ask my topic :D

but im really sorry to say this
but its not what i need i can print all my record and subitems

i need only to compleet print from the icons like on my attach file.

i like to print all the items from the listview not only the record's and the subitems
i need my icons too :D

thanks

dummy1912
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1