Hi
Is it possible to get the actual height of text at runtime . I am using Crystal Report 2016. I want to set the height of another column
Column 1 Column 2 . I want to height of column 1 as Column 2 / 2.
Column 2 text can be single line or multiple lines.
Thanks
Saravanan GanesanPosted Aug 14, 2023, 12:24 PM
In Crystal Reports, directly setting the height of one column based on the content of another column isn't a straightforward process, especially if the content in Column 2 can vary in terms of single/multiple lines. Crystal Reports doesn't provide a built-in way to calculate and dynamically set column heights based on content at runtime.
However, you can achieve similar effects using some workaround:
Conditional Formatting: You can use conditional formatting to change the appearance of objects based on a formula. For example, you could conditionally format the font size of the text in Column 2 based on the number of lines it contains. Although this won't directly adjust the height of the column, it can visually create a similar effect.
Text Wrapping: If the content of Column 2 is expected to vary significantly, you might consider enabling text wrapping in the cells of that column. This would allow the content to flow to multiple lines naturally, and you won't need to calculate the height manually.
Subreports: You could use subreports for Column 1 and Column 2. This way, you can have more control over the layout and sizing of individual columns. However, you'll still need to handle the dynamic height calculation in your main report.
Group Sections: If the structure of your report allows it, you could use group sections. Group the data by some field (e.g., a unique identifier for each record) and then place the data in separate sections. This way, each group section can potentially have its own dynamic formatting.
Remember that Crystal Reports has limitations when it comes to dynamic adjustments of layout and height based on runtime data.
Deepak RawatPosted Aug 11, 2023, 6:02 AM
Using Formulas and Section Heights: You can use formulas to calculate the height of Column 2 and then set the height of Column 1 section based on that calculation. Here's a general outline:
Using Multiple Detail Sections: Create multiple detail sections for the same dataset, each with different column layouts. Then, conditionally show/hide these sections based on the content of Column 2. For example, you can create one detail section with a larger Column 1 and another with a smaller Column 1. Use a conditional formula to determine which section to show.
Using Subreports: You can create a subreport for Column 2 and place it inside Column 1. This way, the height of Column 1 will automatically adjust based on the content of Column 2 in the subreport.