Symptom
Crystal Reports Winform Viewer click events in Microsoft Visual Studio .NET.
Resolution
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