security 0 Posted January 10, 2011 Report Share Posted January 10, 2011 Bom dia... eu escrevi um codigo que faz +- o que eu quero, ou seja passa para o PrintPreviewDialog a informação que é para imprimir... Acontece que falta-me imprimir a ListView. e não consigo fazer... eu vou colocar o codigo que tenho... Private Sub Print_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Dim tipo As String Dim PsqCmb1 As String = "Select * From tbl_aparelho Where ID_aparelho=" & cmbTipo Dim cmd1 As OleDbCommand = coNn.CreateCommand Dim myCommand1 As New OleDbCommand(PsqCmb1, coNn) coNn.Open() Dim leitor1 As OleDbDataReader = myCommand1.ExecuteReader() '-Preenche o formulario com os dados do orçamento dado If leitor1.HasRows() Then leitor1.Read() tipo = IIf(leitor1("tipo") Is DBNull.Value, "''", leitor1("tipo")) End If leitor1.Close() ' Dim marca As String Dim PsqCmb2 As String = "Select *From tbl_marca Where ID_marca=" & cmbMarca Dim cmd2 As OleDbCommand = coNn.CreateCommand Dim myCommand2 As New OleDbCommand(PsqCmb2, coNn) 'coNn.Open() Dim leitor2 As OleDbDataReader = myCommand2.ExecuteReader If leitor2.HasRows Then leitor2.Read() marca = IIf(leitor2("tipo") Is DBNull.Value, "''", leitor2("tipo")) End If leitor2.Close() ' Dim estado As String Dim PsqCmb3 As String = "Select * From tbl_estado_repara Where ID_estadoRepara=" & ComboBox3.SelectedValue Dim cmd3 As OleDbCommand = coNn.CreateCommand Dim myCommand3 As New OleDbCommand(PsqCmb3, coNn) 'coNn.Open() Dim leitor3 As OleDbDataReader = myCommand3.ExecuteReader If leitor3.HasRows Then leitor3.Read() estado = IIf(leitor3("designacao") Is DBNull.Value, "''", leitor3("designacao")) End If leitor3.Close() coNn.Close() Dim x0 As Integer = e.MarginBounds.X = 10 Dim y0 As Integer = e.MarginBounds.Y = 10 Dim cmpr As Integer = e.MarginBounds.Width = 10 Dim alt As Integer = e.MarginBounds.Height = 10 dlgPrintPreview.PrintPreviewControl.Zoom = 1 e.Graphics.DrawRectangle(Pens.Black, e.MarginBounds) 'Alinha a imagem e.Graphics.DrawImage(Image.FromFile(Application.StartupPath & "\..\..\Resources\img_Logo_Tecnimarante.png"), 100, 100) e.Graphics.DrawString("Cliente nº " & TextBox1.Text, New Font("Calibri", 11, FontStyle.Regular), _ Brushes.Gray, 634, 260) e.Graphics.DrawLine(Pens.Gray, 100, 280, 725, 280) e.Graphics.DrawString("Nome de cliente: " & TextBox2.Text, New Font("Calibri", 11, FontStyle.Regular), _ Brushes.Gray, 105, 280) e.Graphics.DrawString("Contacto: " & MaskedTextBox2.Text, New Font("Calibri", 11, FontStyle.Regular), _ Brushes.Gray, 105, 300) e.Graphics.DrawString("Morada: " & TextBox6.Text & ", " & TextBox7.Text & ", " & _ MaskedTextBox1.Text & ", " & TextBox10.Text & ", " & TextBox11.Text, _ New Font("Calibri", 11, FontStyle.Regular), Brushes.Gray, 105, 320) e.Graphics.DrawString("Assistência nº " & Label23.Text, New Font("Calibri", 11, FontStyle.Regular), _ Brushes.Gray, 613, 340) e.Graphics.DrawLine(Pens.Gray, 100, 360, 725, 360) e.Graphics.DrawString("Data: " & DateTimePicker1.Value.Date, New Font("Calibri", 11, FontStyle.Regular), _ Brushes.Gray, 105, 380) e.Graphics.DrawString("Aparelho: " & tipo, New Font("Calibri", 11, FontStyle.Regular), _ Brushes.Gray, 105, 400) e.Graphics.DrawString("Marca: " & marca, New Font("Calibri", 11, FontStyle.Regular), _ Brushes.Gray, 105, 420) e.Graphics.DrawString("Modelo: " & TextBox12.Text, New Font("Calibri", 11, FontStyle.Regular), _ Brushes.Gray, 105, 440) e.Graphics.DrawString("Nº de série: " & TextBox16.Text, New Font("Calibri", 11, FontStyle.Regular), _ Brushes.Gray, 105, 460) e.Graphics.DrawString("Acessórios: " & TextBox4.Text, New Font("Calibri", 11, FontStyle.Regular), _ Brushes.Gray, 105, 480) e.Graphics.DrawString("Avaria: " & TextBox13.Text, New Font("Calibri", 11, FontStyle.Regular), _ Brushes.Gray, 105, 500) e.Graphics.DrawString("Estado: " & estado, New Font("Calibri", 11, FontStyle.Regular), _ Brushes.Gray, 105, 520) e.Graphics.DrawString("Data de reparação: " & DateTimePicker2.Value.Date, New Font("Calibri", 11, FontStyle.Regular), _ Brushes.Gray, 105, 540) 'If ComboBox3.SelectedValue = 2 Then e.Graphics.DrawString("ID", New Font("Calibri", 11, FontStyle.Bold), Brushes.Gray, 105, 580) e.Graphics.DrawString("Material", New Font("Calibri", 11, FontStyle.Bold), Brushes.Gray, 125, 580) e.Graphics.DrawString("Quantidade", New Font("Calibri", 11, FontStyle.Bold), Brushes.Gray, 400, 580) e.Graphics.DrawString("Preço Unit ()", New Font("Calibri", 11, FontStyle.Bold), Brushes.Gray, 480, 580) e.Graphics.DrawString("Valor ()", New Font("Calibri", 11, FontStyle.Bold), Brushes.Gray, 580, 580) 'End If ' There are no more pages. e.HasMorePages = False End Sub se alguem me pudesse arranjar o codigo para imprimir a listview ficaria muito grato. "Innovation distinguishes between a leader and a follower." Steve jobs. Link to post Share on other sites
bioshock 180 Posted January 10, 2011 Report Share Posted January 10, 2011 Há uns tempos escrevi um artigo para a wikipap sobre a impressão de ficheiros incutidos numa listbox, somehow, pode-te dar umas luzes. Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now