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.
PradeepYadhavAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.