Dynamically add/ remove Text component from Databand

Stimulsoft Reports.NET discussion
Post Reply
prajan
Posts: 49
Joined: Tue Apr 23, 2013 1:28 pm

Dynamically add/ remove Text component from Databand

Post by prajan »

Hi,
Could you please tell me how we can dynamically add/ remove Text components from databand.

Thanks in advance
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Dynamically add/ remove Text component from Databand

Post by HighAley »

Hello.

Sorry, maybe we did not exactly understand your question. Could you explain your issue more detailed?

Thank you.
prajan
Posts: 49
Joined: Tue Apr 23, 2013 1:28 pm

Re: Dynamically add/ remove Text component from Databand

Post by prajan »

Hi,
I need to generate a report based on the data retrieved from a SQL stored procedure. The number of columns returned by the proc vary each time. Accordingly I need to change the number of columns displayed. That is why I asked how text components can be dynamically added in the databand under a group header. Can you please let me know how this can be handled?
Thanks
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Dynamically add/ remove Text component from Databand

Post by Alex K. »

Hello,

Please see the sample report in attachment.

Thank you.
Attachments
DynamicCreateReport.zip
(15.46 KiB) Downloaded 589 times
prajan
Posts: 49
Joined: Tue Apr 23, 2013 1:28 pm

Re: Dynamically add/ remove Text component from Databand

Post by prajan »

Thanks for the sample report. I will get back in case of any queries.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Dynamically add/ remove Text component from Databand

Post by Alex K. »

Hello,

Ok. Let us know if you need any additional help.
prajan
Posts: 49
Joined: Tue Apr 23, 2013 1:28 pm

Re: Dynamically add/ remove Text component from Databand

Post by prajan »

Hi,
I am working on a web application and tried as mentioned in the sample. But I am getting the error "DragDrop registration did not succeed" in report.Show(). My code is as shown below. Please let me know if I have missed anything:

Code: Select all

StiReport report = new StiReport();

            report.Dictionary.Clear();
            report.Dictionary.Databases.Clear();
            report.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("SQLConnection", SqldBConnectString));

            DataSet dsBSReport = null;

            StiPage LiabRep = report.Pages[0];
            
            dsBSReport = objBSReport.m_BalanceSheetReport(11, "1/5/2013", "GL", true, "ABC");

            DataTable dtRepDet = dsBSReport.Tables[0];
            DataTable dtUserPC = dsBSReport.Tables[1];
            DataTable dtRepLiab = dsBSReport.Tables[2];
            DataTable dtRepAsst = dsBSReport.Tables[3];

            report.RegData(dsBSReport);

            report.Dictionary.Synchronize();

           
            //Create header group for headers

            StiHeaderBand LiabRepHeader = new StiHeaderBand();
            LiabRepHeader.Height = 0.7;
            LiabRepHeader.Name = "LiabReportHeader";

            LiabRep.Components.Add(LiabRepHeader);

            double columnWidth = LiabRep.Width / ((dtUserPC.Rows.Count + 1) * 2);
            double pos = 0;

            // Add databand in the header text

            StiDataBand dbLiabRepHeader = new StiDataBand();
            dbLiabRepHeader.Height = 0.7;
            dbLiabRepHeader.Name = "dbLiabRepHeader";

            LiabRepHeader.Components.Add(dbLiabRepHeader);

            // Add 'Liabilities' header text

            StiText stitxtLiab = new StiText(new RectangleD(pos, 0, (columnWidth * 2), 0.7));
            stitxtLiab.Text = "Liabilities";
            stitxtLiab.HorAlignment = StiTextHorAlignment.Center;
            stitxtLiab.VertAlignment = StiVertAlignment.Center;
            stitxtLiab.Border.Side = StiBorderSides.All;

            dbLiabRepHeader.Components.Add(stitxtLiab);

            // Add header text for each of the PCs
            int nameIndex = 1;
            foreach (DataRow drUserPC in dtUserPC.Rows)
            {
                pos = pos + (columnWidth * 2);
                StiText hText = new StiText(new RectangleD(pos, 0, (columnWidth * 2), 0.7));
                hText = new StiText(new RectangleD(pos, 0, columnWidth, 0.5));

                hText.Text.Value = drUserPC["ProfitCenter"].ToString() + "/n Amount in Rs.";
                hText.HorAlignment = StiTextHorAlignment.Center;
                hText.Name = "HeaderText" + nameIndex.ToString();
                hText.Border.Side = StiBorderSides.All;
                dbLiabRepHeader.Components.Add(hText);
                nameIndex++;
            }

            report.Compile();

           
            report.Show();

Thanks
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Dynamically add/ remove Text component from Databand

Post by Alex K. »

Hello,

Please send us a sample project which reproduces the issue.
Also please check the sample in attachment.

Thank you.
Attachments
DynamicCreateReportWeb.zip
(320.95 KiB) Downloaded 399 times
Post Reply