0

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!

Edited by pritaeas: Moved.

2
Contributors
1
Reply
4
Views
4 Years
Discussion Span
Last Post by Begginnerdev
0

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

Edited by Begginnerdev

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.