How to make StiText in StiDataBand extend row and break to another line if text is too long?
Posted: Fri Jun 29, 2012 10:02 am
I create reports dynamically, only with dlls, without desinger. When value of the field in the business object is too long, it is just cutted to the width of the single lined StiText control. Here's the code:
What should I do? I tried with CanGrow, CanBreak and SetWordWrap, but unsuccesful.
Code: Select all
StiHeaderBand headerBand = new StiHeaderBand();
headerBand.Height = 0.5;
headerBand.Name = "HeaderBand";
page.Components.Add(headerBand);
StiDataBand dataBand = new StiDataBand();
dataBand.Height = 0.5;
dataBand.Name = "DataBand";
dataBand.BusinessObjectGuid = _report.Dictionary.BusinessObjects[_type.Name].Guid;
page.Components.Add(dataBand);
double pos = 0, columnWidth = StiAlignValue.AlignToMinGrid(page.Width / _headers.Count, 0.1, true);
int nameIndex = 1;
foreach (HeaderInfo header in _headers)
{
double width = header.Width == 0 ? columnWidth : header.Width;
StiText headerText = new StiText(new RectangleD(pos, 0, width, 0.5));
headerText.HorAlignment = StiTextHorAlignment.Center;
headerText.VertAlignment = StiVertAlignment.Center;
headerText.Text.Value = header.UIName;
headerText.Name = "HeaderText" + nameIndex;
if (nameIndex < _headers.Count)
{
headerText.Border.Side = StiBorderSides.Top | StiBorderSides.Left | StiBorderSides.Bottom;
}
else
{
headerText.Border.Side = StiBorderSides.All;
}
headerBand.Components.Add(headerText);
StiText dataText = new StiText(new RectangleD(pos, 0, width, 0.5));
dataText.VertAlignment = StiVertAlignment.Center;
dataText.Text.Value = "{" + _type.Name + "." + header.Name + "}";
dataText.Name = "DataText" + nameIndex;
if (nameIndex < _headers.Count)
{
dataText.Border.Side = StiBorderSides.Left | StiBorderSides.Bottom;
}
else
{
dataText.Border.Side = StiBorderSides.Left | StiBorderSides.Bottom | StiBorderSides.Right;
}
dataBand.Components.Add(dataText);
pos += width;
nameIndex++;
}