Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Hi How can i print listview with database im using phpmyadmin xampp

Hi How can i print listview with database im using phpmyadmin xampp

Scheduled Pinned Locked Moved Visual Basic
graphicsdatabasemysqlhelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kyooshi
    wrote on last edited by
    #1

    im making insert update and delete with database for my activity and the teacher give task to add print and im trying to make on my own but its diffucult for me i hope you can help me out with these. im beginner at visual basic. im using printdocument and printpreviewdialog Here my code Print button

    Private Sub btnprint_Click(sender As Object, e As EventArgs) Handles btnprint.Click
    Dim PrintPreview As New PrintPreviewDialog
    PrintPreview.Document = PrintDocument1
    PrintPreview.ShowDialog()
    End Sub

    Print Document Print Page

    Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
    Dim H As Integer = 0
    H = 50
    e.Graphics.DrawString("PRINT", New Drawing.Font("Times New Roman", 10), Brushes.Black, 50, H)
    For Each Itm As ListViewItem In ListView1.Items
    e.Graphics.DrawString(Itm.Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 50, H)
    e.Graphics.DrawString(Itm.SubItems(0).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
    e.Graphics.DrawString(Itm.SubItems(1).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
    e.Graphics.DrawString(Itm.SubItems(2).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
    e.Graphics.DrawString(Itm.SubItems(3).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
    e.Graphics.DrawString(Itm.SubItems(4).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
    e.Graphics.DrawString(Itm.SubItems(5).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
    e.Graphics.DrawString(Itm.SubItems(6).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
    e.Graphics.DrawString(Itm.SubItems(7).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
    e.Graphics.DrawString(Itm.SubItems(8).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
    e.Graphics.DrawString(Itm.SubItems(9).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
    H += 20
    Next
    End Sub

    here's my ouput Output

    Richard DeemingR L 2 Replies Last reply
    0
    • K Kyooshi

      im making insert update and delete with database for my activity and the teacher give task to add print and im trying to make on my own but its diffucult for me i hope you can help me out with these. im beginner at visual basic. im using printdocument and printpreviewdialog Here my code Print button

      Private Sub btnprint_Click(sender As Object, e As EventArgs) Handles btnprint.Click
      Dim PrintPreview As New PrintPreviewDialog
      PrintPreview.Document = PrintDocument1
      PrintPreview.ShowDialog()
      End Sub

      Print Document Print Page

      Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
      Dim H As Integer = 0
      H = 50
      e.Graphics.DrawString("PRINT", New Drawing.Font("Times New Roman", 10), Brushes.Black, 50, H)
      For Each Itm As ListViewItem In ListView1.Items
      e.Graphics.DrawString(Itm.Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 50, H)
      e.Graphics.DrawString(Itm.SubItems(0).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
      e.Graphics.DrawString(Itm.SubItems(1).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
      e.Graphics.DrawString(Itm.SubItems(2).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
      e.Graphics.DrawString(Itm.SubItems(3).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
      e.Graphics.DrawString(Itm.SubItems(4).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
      e.Graphics.DrawString(Itm.SubItems(5).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
      e.Graphics.DrawString(Itm.SubItems(6).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
      e.Graphics.DrawString(Itm.SubItems(7).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
      e.Graphics.DrawString(Itm.SubItems(8).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
      e.Graphics.DrawString(Itm.SubItems(9).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
      H += 20
      Next
      End Sub

      here's my ouput Output

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      You are drawing every sub-item starting at the same horizontal coordinate. Unsurprisingly, this results in the text of every sub-item overlapping. You need to increase the horizontal coordinate for each sub-item. You can either use the MeasureString method[^] to measure how much space your string will take up, or used fixed coordinates and use the DrawString overload[^] which limits the size of the output to prevent the text from overlapping.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      • K Kyooshi

        im making insert update and delete with database for my activity and the teacher give task to add print and im trying to make on my own but its diffucult for me i hope you can help me out with these. im beginner at visual basic. im using printdocument and printpreviewdialog Here my code Print button

        Private Sub btnprint_Click(sender As Object, e As EventArgs) Handles btnprint.Click
        Dim PrintPreview As New PrintPreviewDialog
        PrintPreview.Document = PrintDocument1
        PrintPreview.ShowDialog()
        End Sub

        Print Document Print Page

        Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        Dim H As Integer = 0
        H = 50
        e.Graphics.DrawString("PRINT", New Drawing.Font("Times New Roman", 10), Brushes.Black, 50, H)
        For Each Itm As ListViewItem In ListView1.Items
        e.Graphics.DrawString(Itm.Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 50, H)
        e.Graphics.DrawString(Itm.SubItems(0).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
        e.Graphics.DrawString(Itm.SubItems(1).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
        e.Graphics.DrawString(Itm.SubItems(2).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
        e.Graphics.DrawString(Itm.SubItems(3).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
        e.Graphics.DrawString(Itm.SubItems(4).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
        e.Graphics.DrawString(Itm.SubItems(5).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
        e.Graphics.DrawString(Itm.SubItems(6).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
        e.Graphics.DrawString(Itm.SubItems(7).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
        e.Graphics.DrawString(Itm.SubItems(8).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
        e.Graphics.DrawString(Itm.SubItems(9).Text, New Drawing.Font("Times New Roman", 10), Brushes.Black, 150, H)
        H += 20
        Next
        End Sub

        here's my ouput Output

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        You are drawing all 10 subitems at the same location on the page. You need to change the X location for each item. The code could be simplified by creating a loop and using a single Font element:

            Dim TnrFont as Drawing.Font = New Drawing.Font("Times New Roman", 10)
            e.Graphics.DrawString("PRINT", TnrFont, Brushes.Black, 50, H)
            For Each Itm As ListViewItem In ListView1.Items
                e.Graphics.DrawString(Itm.Text, TnrFont, Brushes.Black, 50, H)
                Dim Left as Integer = 150
                For subindex as Integer = 0 To 9
                    e.Graphics.DrawString(Itm.SubItems(subindex).Text, TnrFont, Brushes.Black, Left, H)
                    ' Add the offset of the field size to "Left"
                    Left += 100 ' or whatever value to move it to the right on the page
                Next
                H += 20
            Next
        
        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups