How to make StiText in StiDataBand extend row and break to another line if text is too long?

Stimulsoft Reports.Silverlight discussion
Locked
algernon
Posts: 6
Joined: Fri Jun 29, 2012 9:46 am

How to make StiText in StiDataBand extend row and break to another line if text is too long?

Post 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.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

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

Post 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.
algernon
Posts: 6
Joined: Fri Jun 29, 2012 9:46 am

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

Post 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.
Attachments
SimpleSLReport.zip
(6.89 MiB) Downloaded 378 times
Last edited by algernon on Thu Jul 05, 2012 7:07 am, edited 10 times in total.
algernon
Posts: 6
Joined: Fri Jun 29, 2012 9:46 am

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

Post by algernon »

Ok, I managed to add the code, sorry for trouble. Now You can enlight me in the matter...
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

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

Post by HighAley »

Hello.

You should also set next properties:

Code: Select all

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