• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1033
  • Last Modified:

height of detail section

Is this possible open an existing crystal report increase the height of the detail section and save it in runtime.

crSection = Report.Sections.Item("D")

how to set the height of this section during runtime ?

Reason is to make the details fit the whole page based on number of records.
0
PradeepYadhav
Asked:
PradeepYadhav
1 Solution
 
PradeepYadhavAuthor Commented:
Increasing the height will increase the space between records
0
 
mlmccCommented:
I don't think it is.  

I don't have CR here but if you open a report in Crystal and Right click(left side) the detail section is SIZE an option?  
I know if you Click
FORMAT --> FORMAT SECTION
Height is not an option

Is the detail section the same size as the field boxes?
If so you might be able to use an application to
Open the report
Change the size of the field
Save the report
Repeat to set the field height back.

mlmcc
0
 
ebolekCommented:
mlmcc he is asking about doing it in the runtime I think.

You can only do this with report application server RAS

//WORKS WELL FOR THE DETAIL AREA GENERATES THE FIELDS
CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject field;
Section sec = m_crReportDocument.ReportDefinition.DetailArea.Sections[0];
for(int i = 0; i < arr.Count; i++)
{
iField = m_crReportDocument.Database.Tables[0].DataFields.Find(arr[i].ToString(), CrFieldDisplayNameTypeEnum.crFieldDisplayNameName, CeLocale.ceLocaleUserDefault);
field = CreateFieldObject(m_crReportDocument,(string)arr[i],tableName,4800*i, 0, 2800, 200);
m_crReportDocument.ReportDefController.ReportObjectController.Add(field, sec, -1);
}

//DOES NOT WORK FOR THE PAGE HEADER AREA GENERATES THE FIELDS
CrystalDecisions.ReportAppServer.ReportDefModel.FieldHeadingObject field;
Section sech = m_crReportDocument.ReportDefinition.PageHeaderArea.Sections[0];
for(int i = 0; i < arr.Count; i++)
{

field = CreateFieldHeadingObject((string)arr[i],tableName,4800*i, 0, 2800, 200);
m_crReportDocument.ReportDefController.ReportObjectController.Add(field, sech, -1);
}




CrystalReportViewer1.ReportSource = m_crReportDocument;



FieldObject CreateFieldObject(ReportClientDocument m_crReportDocument, string strField, string strTable, int left, int top, int width, int height)
{
int iField;
Field oField;

int iTable;
CrystalDecisions.ReportAppServer.DataDefModel.Table oTable;
FieldObject field;
CrystalDecisions.ReportAppServer.ReportDefModel.Font font;
CrystalDecisions.ReportAppServer.ReportDefModel.FontColor fontcolor;

// create a 10 point arial font
font = new CrystalDecisions.ReportAppServer.ReportDefModel.Font();
font.Bold = true;
font.Size = 10;
font.Name = "Tahoma";


// create font color and set font to 10 point arial
fontcolor = new CrystalDecisions.ReportAppServer.ReportDefModel.FontColor();
fontcolor.Font = font;

// find database field
iTable = m_crReportDocument.Database.Tables.FindByAlias(strTable);
oTable = (CrystalDecisions.ReportAppServer.DataDefModel.Table)m_crReportDocument.Database.Tables[iTable];
iField = oTable.DataFields.Find(strField, CrFieldDisplayNameTypeEnum.crFieldDisplayNameName, CeLocale.ceLocaleUserDefault);
oField = (Field)oTable.DataFields[iField];

// create field object
field = new FieldObject();

// fill field properties
field.Kind = CrReportObjectKindEnum.crReportObjectKindField;
field.FieldValueType = oField.Type;
field.DataSource = oField.FormulaForm;
field.Left = left;
field.Top = top;
field.Width = width;
field.Height = height;
field.FontColor = fontcolor;


return (field);
}


FieldHeadingObject CreateHeadFieldObject(string strField, string strTable, int left, int top, int width, int height)
{


int iField;
Field oField;

int iTable;
CrystalDecisions.ReportAppServer.DataDefModel.Table oTable;
FieldObject field;
CrystalDecisions.ReportAppServer.ReportDefModel.Font font;
CrystalDecisions.ReportAppServer.ReportDefModel.FieldHeadingObject fieldhead;
CrystalDecisions.ReportAppServer.ReportDefModel.FontColor fontcolor;

// create a 10 point arial font
font = new CrystalDecisions.ReportAppServer.ReportDefModel.Font();
font.Bold = true;
font.Size = 10;
font.Name = "Tahoma";


// create font color and set font to 10 point arial
fontcolor = new CrystalDecisions.ReportAppServer.ReportDefModel.FontColor();
fontcolor.Font = font;

//CREATE FIELD HEADING OBJECT
fieldhead = new FieldHeadingObject();
fieldhead.FieldObjectName = "test";
fieldhead.Left = left;
fieldhead.Top = top;
fieldhead.Width = width;
fieldhead.Height = height;
fieldhead.FontColor = fontcolor;
fieldhead.Kind = CrReportObjectKindEnum.crReportObjectKindFieldHeading;


return (fieldhead);
}

Regards
Emre
0
 
vidruCommented:
With the RDC, you can simply set the height at runtime like this:

Report.Sections("D").Height = intHeight

If for some reason you also need to change the height or font of the fields in the Details section:

Dim crxSection As CRAXDRT.Section
Dim crxFieldObject As CRAXDRT.FieldObject
Set crxSection = Report.Sections("D")
For i = 1 To crxSection.ReportObjects.Count
    Select Case crxSection.ReportObjects(i).Kind
        Case crFieldObject
            Set crxFieldObject = crxSection.ReportObjects(i)
            crxFieldObject.Height = 150
            crxFieldObject.Font.Size = 8
            crxFieldObject.Font.Name = "Arial"
    End Select
Next i

-dave
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now