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.
Programically Component attachment
Programically Component attachment
Hello,
You can use the following code:
Thank you.
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);