on 06-13-2016 12:38 PM
I have tried a few different way but can't seem to find what I am looking for...
I am running a Crystal Report programmatically using c# WinForms, I need to be able to access the values of the fields in the group header 1 much like the way Visual CUT does when it runs the reports in its scheduler.
I have managed to get a hold of the GroupHeader1 Value by doing:
crystalReport.Rows[i].Rows.ToString();
and thought something like
crystalReport.Rows[i].Rows.Columns[0].Value
would be available, but can't seem to find where I would be able to access the fields and their values at runtime.
I can see the formula I need by going through:
crystalReport.DataDefinition.FormulaFields["ToEmail"].Text
But that just gives me the original value in the formula rather than what the report displays and sees.
I don't load the datasource of the report programmatically either, that is handled by the report itself, so can't even use that info.
Any pointers in the right direction would be greatly appreciated as it is frustrating the life out of me.
Thanks.
Moved to CR for .NET sdk forum.
Need to know what version of the SDK you are using and what verision of VS?
Don
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, you did not have to go to SP 16 but no problem...
I'm curious, why do you need the data values?
If you add a doubleClick Event you can get the Data this way:
private void crystalReportViewer1_DoubleClickPage(object sender, PageMouseEventArgs e)
{
//// do not edit this works
//CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rptClientDoc;
//rptClientDoc = rpt.ReportClientDocument;
//crystalReportViewer1.SetFocusOn(UIComponent.Page);
//if (e.ObjectInfos != null)
//{
// btnReportObjects.Text = "";
// btnReportObjects.Text += "Number of items in selected Row: " + e.ObjectInfos.Length.ToString() + "\n\n";
// foreach (ObjectInfo oi in e.ObjectInfos)
// {
// //btnReportObjects.Text += ">>>OBJECT : " + t + " <<<" + "\n";
// btnReportObjects.Text += "Fld Text: " + oi.Text.ToString() + "\n";
// btnReportObjects.Text += "DataContext: " + oi.DataContext.ToString() + "\n";
// btnReportObjects.Text += "GroupNamePath: " + oi.GroupNamePath.ToString() + "\n";
// btnReportObjects.Text += "Hyperlink: " + oi.Hyperlink.ToString() + "\n";
// try
// {
// foreach (FormulaField resultField in rptClientDoc.DataDefController.DataDefinition.FormulaFields)
// {
// if ((resultField.UseCount > 0) && (resultField.Text == oi.Text))
// {
// CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject objField;
// objField = (CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject)rptClientDoc.ReportDefController.ReportDefinition.FindObjectByName(resultField.Text.ToString());
// richTextBox1.Text += "Formula field object: " + objField.Name.ToString() + "\n"; // oi.DataContext.ToString() ;
// }
// }
// }
// catch (Exception ex)
// {
// MessageBox.Show("ERROR: " + ex.Message);
// return;
// }
// btnReportObjects.Text += "ObjectType: " + oi.ObjectType.ToString() + "\n";
// btnReportObjects.Text += "Tooltip: " + oi.ToolTip.ToString() + "\n";
// btnReportObjects.Text += "========================\n";
// }
// btnReportObjects.AppendText(" 'End' \n");
//}
////do not edit - this works
// Gary Chang sent me this not sure how it's diff than above but it's better
CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rptClientDoc;
rptClientDoc = rpt.ReportClientDocument;
//DateTime dtStart;
//dtStart = DateTime.Now;
//btnSQLStatement.Text += "\nReport End time: \n" + dtStart.ToString();
rptClientDoc.ReportOptions.ConvertNullFieldToDefault = true;
rptClientDoc.ReportOptions.ConvertOtherNullsToDefault = true;
btnReportObjects.Text = "";
int t = 0;
if (e.ObjectInfos != null)
{
foreach (ObjectInfo oi in e.ObjectInfos)
{
try
{
if (oi.ObjectType.ToString() != "GroupChart")
{
if (oi.ObjectType.ToString() != "OleObject")
{
if (oi.ObjectType.ToString() != "CrossTab")
{
// This is the field you double clicked on, in the viewer
if (oi.Name == e.ObjectInfo.Name)
btnReportObjects.Text += @">>> SELECTED OBJECT - you clicked on<<<\n";
btnReportObjects.Text += "DataContext: " + oi.DataContext.ToString() + "\n";
btnReportObjects.Text += "GroupNamePath: " + oi.GroupNamePath.ToString() + "\n";
btnReportObjects.Text += "Hyperlink: " + oi.Hyperlink.ToString() + "\n";
string textBox1 = String.Empty;
foreach (FormulaField resultField in rptClientDoc.DataDefController.DataDefinition.FormulaFields)
{
CrystalDecisions.ReportAppServer.ReportDefModel.ReportObjects FormulaFldobjs;
FormulaFldobjs = rptClientDoc.ReportDefController.ReportObjectController.GetReportObjectsByKind(CrReportObjectKindEnum.crReportObjectKindField);
t = rptClientDoc.DataDefController.DataDefinition.FormulaFields.FindIndexOf(resultField);
CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject objField;
objField = (CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject)FormulaFldobjs[t];
CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject objField2 = (CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject)objField.Clone(true);
if (oi.Name.ToString() == objField2.Name.ToString())
{
btnReportObjects.Text += "Name: " + oi.Name.ToString() + " -> " + objField2.DataSourceName.ToString() + "\n";
}
t++;
}
//btnReportObjects.Text += "Name: " + oi.Name.ToString() + "\n";
btnReportObjects.Text += "Value: " + oi.Text.ToString() + "\n";
btnReportObjects.Text += "ObjectType: " + oi.ObjectType.ToString() + "\n";
btnReportObjects.Text += "Tooltip: " + oi.ToolTip.ToString() + "\n";
btnReportObjects.Text += "========================\n";
//btnReportObjects.Text += richTextBox1;
btnReportObjects.AppendText("\n\n");
}
}
}
}
catch (Exception ex)
{
MessageBox.Show("ERROR: " + ex.Message);
}
}
}
Don
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.