Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,077 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,755 people online right now. Registration is fast and FREE... Join Now!




Printing listbox content

 
Reply to this topicStart new topic

Printing listbox content

barman
26 Feb, 2008 - 05:17 PM
Post #1

New D.I.C Head
*

Joined: 20 Feb, 2008
Posts: 2

I generate random number and it is of four columns in the listbox. I want to print it out. With the following VB.Net code, it prints only the first column, not the other three columns. Can any one help me, so that I may have all these columns printed out.


CODE

Public Class Form1
    Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        PrintDocument1.Print()
    End Sub
    Private Sub PrintPrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        Dim printFont As New Font("Arial", 12)
        Dim lineHeightSingle As Single = printFont.GetHeight + 2
        Dim horizontalPrintLocationSingle As Single = e.MarginBounds.Left
        Dim verticalPrintLocationSingle As Single = e.MarginBounds.Top
        Dim printLineString As String
        Dim listIndexInteger As Integer
        For listIndexInteger = 0 To Me.ListBox1.Items.Count - 1
            verticalPrintLocationSingle += lineHeightSingle
            printLineString = Me.ListBox1.Items(listIndexInteger).ToString
            e.Graphics.DrawString(printLineString, printFont, Brushes.Black, horizontalPrintLocationSingle, verticalPrintLocationSingle)
        Next listIndexInteger

    End Sub

User is offlineProfile CardPM
+Quote Post

Jayman
RE: Printing Listbox Content
26 Feb, 2008 - 10:12 PM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,319



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
Use code.gif tags when posting code.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 11:14PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month