SAP Knowledge Base Article - Public

1202102 - Crystal Reports Winform Viewer click events in Microsoft Visual Studio .NET

Symptom

Crystal Reports Winform Viewer click events in Microsoft Visual Studio .NET.

Resolution

ClickPage and DoubleClickPage events have been added to the Crystal Reports Winform Viewer"s events. These events also have added an ObjectInfo class that allows you to retrieve properties of the object on the viewer that was clicked. These events are only available in Crystal Reports XI Release 2 and above.
 
Properties that are accessible from the ObjectInfoClass are:
 
ObjectInfo.DataContext
Gives the datacontext information of the field that was clicked.
ObjectInfo.GroupNamePath
Gives the full groupnamepath of the field that was clicked.
ObjectInfo.ObjectType
Returns the Object type (ie Chart, DatabaseField, DetailSection etc.).
ObjectInfo.Name
The Name of the report object clicked.
ObjectInfo.Text
The value of the report object clicked.
ObjectInfo.ToolTip
The tooltip text of the object clicked.
ObjectInfo.Hyperlink
The Hyperlink information of the object clicked.

 

C# sample code:

namespace CRXIR2_VS2005_GetReportObjectClicked
{
    public partial class Form1 : Form
    {
        ReportDocument crReport;

        public Form1()
        {
            InitializeComponent();

            // Create an instance of the report
            crReport = new CrystalReport1();

            crystalReportViewer1.ReportSource = crReport;
        }

                // Ensure you are using CR XI Release 2 and at minimum BusinessObjects XI Release 2 Service Pack 1 (SP1)
                // and BusinessObjects XI Release 2 Monthly Hot Fix 1 (MHF1)

        private void crystalReportViewer1_ClickPage(object sender, CrystalDecisions.Windows.Forms.PageMouseEventArgs e)
        {
            // Collect the report object name and type.
            string msg = "Report Object: " + e.ObjectInfo.Name.ToString()
                + " (" + e.ObjectInfo.ObjectType.ToString() + ")";

            // Some report objects won't have text properties; verify that the property isn't null
            if (e.ObjectInfo.Text != null)
            {
                msg += "... Text: " + e.ObjectInfo.Text.ToString();
            }

            // Display the collected information in a message box.
            MessageBox.Show(msg);
        }

         private void crystalReportViewer1_Load(object sender, EventArgs e)
        {

        }
    }
}

Keywords

events viewer windows net ClickPage DoubleClickPage ObjectInfo class , 5249694 , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , How To

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio ; SAP Crystal Reports, version for Visual Studio .NET 2008