Results 1 to 2 of 2

Thread: combobox to print preview question

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2006
    Posts
    26

    combobox to print preview question

    i am having trouble creating a command which will allow me to will display a print preview of all or individually selected items in my combo box. the only thing i get when i run the program is a blank print preview with nothing on it from the combo box. could someone please get me on the right road?? this is what my code looks like in my form:


    Private Sub PrintSubjectsToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintSubjectsToolStripMenuItem1.Click

    'begin the process for print the subject items.

    With Me
    If .subjectComboBox.SelectedIndex = -1 Then
    'select (none) if nothing selected.
    .subjectComboBox.SelectedIndex = 0

    End If
    If .subjectComboBox.SelectedIndex <> -1 Then
    ' items selected.
    .PrintPreviewDialog1.Document = PrintDocument1
    PrintPreviewDialog1.ShowDialog()


    Else
    'no item selected
    MessageBox.Show("select a item from the book list", _
    "print selection", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

    End If

    End With

    End Sub
    Last edited by huey; Feb 7th, 2007 at 01:00 PM.

  2. #2
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397

    Re: combobox to print preview question

    Quote Originally Posted by huey
    i am having trouble creating a command which will allow me to will display a print preview of all or individually selected items in my combo box. the only thing i get when i run the program is a blank print preview with nothing on it from the combo box. could someone please get me on the right road?? this is what my code looks like in my form:


    Private Sub PrintSubjectsToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintSubjectsToolStripMenuItem1.Click


    Code:
     
    VB Code:
    1. With Me
    2.             If .subjectComboBox.SelectedIndex = -1 Then
    3.                 'select (none) if nothing selected.
    4.                 .subjectComboBox.SelectedIndex = 0
    5.  
    6.             End If
    7.             If .subjectComboBox.SelectedIndex <> -1 Then
    8.                 ' items selected.
    9.                 .PrintPreviewDialog1.Document = PrintDocument1
    10.                 PrintPreviewDialog1.ShowDialog()
    11.  
    12.  
    13.             Else
    14.                 'no item selected
    15.                 MessageBox.Show("select a item from the book list", _
    16.                 "print selection", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
    17.  
    18.             End If
    19.  
    20.         End With
    Thats interesting.

    You have [CODE] [VBCODE]code here[/VBCODE][/CODE]
    and it scrunched up your code.

    Perhaps you could drop your [CODE][/CODE] Tags?
    Then it would look like this:

    VB Code:
    1. With Me
    2.             If .subjectComboBox.SelectedIndex = -1 Then
    3.                 'select (none) if nothing selected.
    4.                 .subjectComboBox.SelectedIndex = 0
    5.  
    6.             End If
    7.             If .subjectComboBox.SelectedIndex <> -1 Then
    8.                 ' items selected.
    9.                 .PrintPreviewDialog1.Document = PrintDocument1
    10.                 PrintPreviewDialog1.ShowDialog()
    11.  
    12.  
    13.             Else
    14.                 'no item selected
    15.                 MessageBox.Show("select a item from the book list", _
    16.                 "print selection", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
    17.  
    18.             End If
    19.  
    20.         End With

    Also, you might want to talk to Hack about moving this into the VBNet area.


    -Lou

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width