Page 1 of 1

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
by algernon
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:

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++;
}
What should I do? I tried with CanGrow, CanBreak and SetWordWrap, but unsuccesful.

Re: How to make StiText in StiDataBand extend row and break

Posted: Sat Jun 30, 2012 12:18 pm
by HighAley
Hello.
algernon wrote: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:

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++;
}
What should I do? I tried with CanGrow, CanBreak and SetWordWrap, but unsuccesful.
We couldn't find where do you use CanGrow and CanBrake properties.
Please, try to add next code:
dataText.CanGrow = true;
dataText.CanBreak = true;
If you still have any problem. Please, send us a working project with all data for analysis.

Thank you.

Re: How to make StiText in StiDataBand extend row and break

Posted: Tue Jul 03, 2012 12:52 pm
by algernon
I attach the working copy then... Last name on the list doesn't break.

And offtopic:

Code: Select all

			   if (nameIndex < _headers.Count)
				{
					headerText.Border.Side = StiBorderSides.Top | StiBorderSides.Left | StiBorderSides.Bottom;
				}
				else
				{
					headerText.Border.Side = StiBorderSides.All;
				}
				//if (nameIndex > 1)
				//{
				//    headerText.Border.Side = StiBorderSides.Top | StiBorderSides.Right | StiBorderSides.Bottom;
				//}
				//else
				//{
				//    headerText.Border.Side = StiBorderSides.All;
				//}
When I change the code on top with the commented one, some borders disappears (only if brush for background is specified). Strange.

Re: How to make StiText in StiDataBand extend row and break

Posted: Thu Jul 05, 2012 7:06 am
by algernon
Ok, I managed to add the code, sorry for trouble. Now You can enlight me in the matter...

Re: How to make StiText in StiDataBand extend row and break

Posted: Thu Jul 05, 2012 10:41 am
by HighAley
Hello.

You should also set next properties:

Code: Select all

dataText.WordWrap = true;
dataText.GrowToHeight = true;
Thank you.