Programically Component attachment

Stimulsoft Reports.WEB discussion
Post Reply
uday
Posts: 1
Joined: Thu Jun 03, 2010 7:57 am
Location: Kolkata, India

Programically Component attachment

Post by uday »

Let me know, how can i attach a component through code.

Like I have a report file whose name is Report.mrt, who has a databind and the databind contains two text box one for Name and another for city,
Now I want to add another text box through coding for Phone.
Note that the data source consist all filed [Name, City, Phone, etc.]

Please give me an example.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Programically Component attachment

Post by Alex K. »

Hello,

You can use the following code:

Code: Select all

StiReport report = new StiReport();
report.Load(@"D:\Sample report.mrt");
StiDataBand dataBand = report.GetComponents()["DataBand1"] as StiDataBand;
StiText textComponentAdd = new StiText();
textComponentAdd.Height = 1;
textComponentAdd.Width = 1;
textComponentAdd.Left = 10;
textComponentAdd.Name = "TextPhone";
textComponentAdd.Text = "{DataSource.Phone}";
textComponentAdd.Parent = dataBand;
dataBand.Components.Add(textComponentAdd);
Thank you.
Post Reply