Datagrid Impr

Páginas: 2 (403 palabras) Publicado: 18 de diciembre de 2014
Public Class Form1

' Variable a nivel de clase para recordar en qué punto nos hemos quedado
Dim i As Integer = 0

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
Me.Fill_DataGrid()
End Sub

Private Sub Fill_DataGrid()

' TODO: rellenar con el código que obtiene los datos de donde seanecesario
' Por ejemplo:

Me.DataGridView1.DataSource = dataSet
Me.DataGridView1.DataMember = "Table"
End Sub

Private Sub Button1_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.PrintDocument1.Print()
End Sub

Private Sub printDocument1_PrintPage(ByVal sender As Object, ByVal e AsSystem.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
' Definimos la fuente que vamos a usar para imprimir
' en este caso Arial de 10
Dim printFont AsSystem.Drawing.Font = New Font("Arial", 10)
Dim topMargin As Double = e.MarginBounds.Top
Dim yPos As Double = 0
Dim linesPerPage As Double = 0
Dim count As Integer = 0
Dimtexto As String = ""
Dim row As System.Windows.Forms.DataGridViewRow

' Calculamos el número de líneas que caben en cada página
linesPerPage = e.MarginBounds.Height /printFont.GetHeight(e.Graphics)

' Imprimimos las cabeceras
Dim header As DataGridViewHeaderCell
For Each column As DataGridViewColumn In DataGridView1.Columnsheader = column.HeaderCell
texto += vbTab + header.FormattedValue.ToString()
Next

yPos = topMargin + (count * printFont.GetHeight(e.Graphics))e.Graphics.DrawString(texto, printFont, System.Drawing.Brushes.Black, 10, yPos)
' Dejamos una línea de separación
count += 2

' Recorremos las filas del DataGridView hasta que llegemos...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • IMPR
  • Confugurar Datagrid
  • Datagrid
  • DAPU 104 FUS IMPR
  • Informe Materiales De Impr
  • Tiempo Duracion Alimentos Para IMPR
  • Encuesta Impr
  • Impr Camii

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS