Skip to Content
0
Former Member
Apr 02, 2013 at 04:35 PM

How to create own button in CrystalReportViewer1?

421 Views

How to create own button in CrystalReportViewer1?

I did created button, but when I run the report it doesn’t
show up. I am Vb 2008 and CrystalReport 8

I have two forms main and report. Report review works and
prints fine. I need to update in SQL if report is printed on which date.

I try this:

'find the print button
control and attach an event to it

For Each Obj As Object In myToolStrip.Items

If TypeOf Obj Is ToolStripButton Then

'Adding a handler for our propose

Dim b As ToolStripButton = CType(Obj, ToolStripButton)

If b.ToolTipText = "Print Report" Then

AddHandler CType(Obj, ToolStripButton).Click, AddressOf printButton_Click

End If

End If
Next

It never went to PrintButton_Click.

Now, I created
button name is PrintButton, but PrintButton doesn’t show up in CrystalReportViewer1

Private Sub PrintButton_Click(ByVal sender As System.Object, ByVal e As system.EventArgs) Handles PrintButton.Click

Dim dialog As New PrintDialog

dialog.UseEXDialog = True

dialog.AllowSomePages = True

If dialog.ShowDialog() = DialogResult.OK Then

Dim objRpt As ReportDocument = CType(Me.CrystalReportViewer1.ReportSource,
ReportDocument)

objRpt.PrintOptions.PrinterName = dialog.PrinterSettings.PrinterName

objRpt.PrintToPrinter(1, False, 0, 0)

PrintedDate()

Else

MessageBox.Show("print cancel")

Return

End If

End Sub

Can anyone out there help me Please?
I have been trying for two months.

Thank you