on 10-08-2015 9:35 AM
Hi Team,
I would like to know whether we can create a custom toolbar for cr viewer and if yes could somebody share sample for that.
Thanks
Jibi
You can, but you're in for a lot of pain and as soon as you or anyone else updates the CR runtime, it may not work.
See this on how to create custom buttons. The blow is from an internal resource. Note that there is a reason why it is internal (see my note above):
Customized print button cna be added to the Crystal Reports Viewer by using ToolStrip.
Please refer to the following code to add a customized print button to the Crystal Reports Viewer control:
--------------------------------------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Drawing.Printing;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
CrystalReport1 cr;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
ToolStrip ts;
ts = (ToolStrip)crystalReportViewer1 .Controls[3];
ToolStripButton printbutton = new ToolStripButton();
printbutton.Image = ts.Items[1].Image;
ts.Items.Remove(ts.Items[1]);
ts.Items.Insert(1, printbutton);
ts.Items[1].Click += new EventHandler(this.CaptureEvent);
cr = new CrystalReport1();
this.crystalReportViewer1.ReportSource = cr;
}
private void CaptureEvent(Object Sender, EventArgs e)
{
try
{ // Create a Print Dialog
PrintDialog printDialog1 = new PrintDialog();
// Create a Print Document
PrintDocument pd = new PrintDocument();
printDialog1.Document = pd;
printDialog1.ShowNetwork = true;
printDialog1.AllowSomePages = true;
DialogResult result = printDialog1.ShowDialog();
if (result == DialogResult.OK)
{
MessageBox.Show("Print button has been selected !!!");
PrintReport(printDialog1.PrinterSettings.PrinterName);
}
else if (result == DialogResult.Cancel)
{
MessageBox.Show("Cancel button has been selected !!!");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void PrintReport(string printerName)
{
// Select the printer.
cr.PrintOptions.PrinterName = printerName;
/* Print the report. Set the startPageN and endPageN
parameters to 0 to print all pages.*/
cr.PrintToPrinter(1, false, 0, 0);
}
}
}
--------------------------------------------------------------------------------------------------------------------------------------------------
Also see KBA: 1592578 - How to disable/hide individual buttons in the Crystal Reports .NET Windows Form viewer
KBA: 1408996 - How to add a button to the Crystal Reports winform viewer in Visual Studio .NET
KBA: 1484309 - How to remove "Main Report" static text box in CR 2008 viewer for VS .NET?
KBA: 1498827 - How to set the list of available export types in the .NET CrystalReportViewer control
And there may be more. Use the search box in top right corner (string like 'Crystal net button' will be good to start with)
- Ludek
Senior Support Engineer AGS Product Support, Global Support Center Canada
Follow me on Twitter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for sharing the code.Actually I am looking for a asp.net web based solution. The one which you provided is for a Windows based application. Earlier version we were able to do the same for web based one by getting the control array and now its returning control array count as 2. I think now current version its done by JavaScript library and if am right is there anyway to override the existing functionality with customized version of code (JavaScript or c#).
Thanks
Jibi
Hi Team,
Can anybody help me on this. I am currently stuck with my upgrade with the new version of Crystal Report. There were lots of customized code exist in the old code and after the upgrade
none of them works fine.
Your help on this greatly appreciated.
Thanks
Jibi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.