Link to home
Start Free TrialLog in
Avatar of PradeepYadhav
PradeepYadhav

asked on

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.
Avatar of PradeepYadhav
PradeepYadhav

ASKER

Increasing the height will increase the space between records
Avatar of Mike McCracken
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
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
ASKER CERTIFIED SOLUTION
Avatar of vidru
vidru

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial