buen dia a todos
alguien que me pudiera ayudar a como imprimir el contenido de group box en visual studio , se los agradesere toda la vida, uso el printform pero no me resulto alguien me podra ayudar
gracias
![]()
buen dia a todos
alguien que me pudiera ayudar a como imprimir el contenido de group box en visual studio , se los agradesere toda la vida, uso el printform pero no me resulto alguien me podra ayudar
gracias
![]()
Amigo,
Un groupbox es un contenedor de otros controles, lo que aparentemente necesitas es imprimir toda la forma con el printform. Yo lo que hice es imprimo
la forma que contiene todo lo que quiero y acomodado tal como lo quiero.
(Te recomiendo bajar el powerpacks). Luego agrego un botón para "Imprimir" y el evento click de ese botón lo hago que llame la siguiente sub:
Private Sub PrintLabel_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs ) Handles PrintLabel.LinkClicked
DesSeleccionaTodo()
PrintPreviewLabel.Visible = False
PrintLabel.Visible = False
PrintForm1.PrintAction = Printing.PrintAction.PrintToPrinter
Dim hola As New PrintDialog
hola.AllowPrintToFile = True
hola.PrinterSettings.DefaultPageSettings.Margins.L eft = 15
hola.PrinterSettings.DefaultPageSettings.Margins.R ight = 5
hola.PrinterSettings.DefaultPageSettings.Margins.T op = 5
hola.PrinterSettings.DefaultPageSettings.Margins.B ottom = 5
hola.PrinterSettings.DefaultPageSettings.Landscape = True
Dim ps As New PaperSize("Media Carta", 550, 850)
ps.PaperName = PaperKind.Custom
hola.PrinterSettings.DefaultPageSettings.PaperSize = ps
Try
If hola.ShowDialog() = Windows.Forms.DialogResult.OK Then
With (PrintForm1)
.PrinterSettings = hola.PrinterSettings
.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.ClientAr eaOnly)
End With
End If
Catch ex As Exception
MsgBox("Error en Impresora" & vbCrLf & ex.Message, MsgBoxStyle.Critical)
End Try
PrintPreviewLabel.Visible = True
PrintLabel.Visible = True
Me.Dispose()
Me.Close()
End Sub
Private Sub DesSeleccionaTodo()
For Each ctr In Controls
If TypeOf ctr Is TextBox Then
ctr.select(1, 0)
ElseIf TypeOf ctr Is myGroupBox Then
For Each contr In ctr.controls
If TypeOf contr Is TextBox Then
contr.select(1, 0)
End If
Next
End If
Next
End Sub
Suerte.