I am trying to print all the contents of a combobox in a program.

For example:

ComboBox1 Contents:
Yes
No
Maybe
No opinion

My code so far for PrintDocument1:

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

        Dim horizontalPrintPosition As Single
        Dim verticalPrintPosition As Single
        Dim PrintFont As New Font("Arial", 12)

        e.Graphics.DrawString("Info from ComboBox1 would go here", PrintFont, Brushes.Black, horizontalPrintPosition, verticalPrintPosition)

    End Sub

My desired output would be:

- Combo Box -
Yes
No
Maybe
No opinion
-- -- - -- --

Thanks!

You can try something like this:

For i = 0 To ComboBox1.Items.Count - 1
   e.Graphics.DrawString(ComboBox1.Items(i), PrintFont, Brushes.Black, horizontalPrintPosition, verticalPrintPosition)

   'Leave some space for the next item.
   verticalPrintPosition += 5
Next
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.