Current filter:
                                You should refresh the page.
                                  • I want to make a copy of the table.
                                    Please help me how to implement copying and pasting the table with c # code.
                                    The copytoclipboard function could not be found in xrtable.

                                Show all comments
                                • Elliot (DevExpress Support) 09.19.2019

                                  Hello,

                                  You final goal is unclear to me. Would you please describe the task you are trying to accomplish in greater detail? This will allow us to find a better solution for this issue.

                                  Thanks,
                                  Elliot

                                • Customer91543 09.19.2019

                                  I have a template file(report file) and it has a table.
                                  If the user enters a number of table, the table in the template needs to be copied and created below.
                                  It should look exactly the same.(Contents and borders in cells)

                                • Elliot (DevExpress Support) 09.19.2019

                                  Hello,

                                  Would you please post your report layout (*.repx file) version so we can research it and try to find an appropriate solution? Use instructions from the Storing Report Layouts topic to obtain a report layout.

                                  Thanks,
                                  Elliot

                                • Customer91543 09.19.2019

                                  I attached the file.

                                • Customer91543 09.19.2019

                                  Copies of table should have cells from 4th row of the original table.(It means I should remove 1st,2nd,3rd row)

                                • Elliot (DevExpress Support) 09.20.2019

                                  Hello,

                                  Unless I am mistaken, you want to paste a table from the 'Example' report to another report. If so, you can create an instance of the 'Example' report and find a table using the XtraReport.FindControl method. Then, modify it according to your requirements and add it to a new report.

                                  [C#]
                                  XtraReport1 report = new XtraReport1(); XRTable table = report.FindControl("table1", true) as XRTable; //modify a table //.....   //create an empty report XtraReport r = new XtraReport(); DetailBand b = new DetailBand(); r.Bands.Add(b); //add a table to a report r.Bands[BandKind.Detail].Controls.Add(table);   ReportPrintTool tool = new ReportPrintTool(r); tool.ShowPreview();

                                  Thanks,
                                  Elliot

                                • Customer91543 09.20.2019

                                  I'm sorry but it's not what I want.
                                  What I asked is to copy a table within that report.
                                  The goal is to create several new instances by deep copying the tables in the report.

                                • Elliot (DevExpress Support) 09.23.2019

                                  Hello,

                                  Thank you for your clarification. In this case, you can create a separate instance of a report to copy a table. Here is a corresponding code snippet:

                                  [C#]
                                  XtraReport1 report = new XtraReport1(); XRTable table = report.FindControl("table1", true) as XRTable; XtraReport1 report2 = new XtraReport1(); table.LocationF = new PointF(0, 800); report2.Bands[BandKind.Detail].Controls.Add(table); ReportPrintTool tool = new ReportPrintTool(report2); tool.ShowPreview();

                                  Thanks,
                                  Elliot

                                • Customer91543 09.23.2019

                                  This method seems somewhat different from what I need.
                                  If I need 10 tables in a report, it would be inefficient to make 10 copies of the template file and instantiate each table.
                                  (Need to copy 1 file per table)

                                  In Report Designer, there was a way for the user to copy with ctrl + c and paste with ctrl + v.
                                  Can't I use this in code?

                                1 Solution

                                Creation Date Importance Sort by

                                Hello,

                                You can serialize the XRTable control located in a report and deserialize it to create a copy of this table. Here is a corresponding code snippet:

                                [C#]
                                private void Form1_Load(object sender, EventArgs e) { XtraReport1 report = new XtraReport1(); XRTable table = report.FindControl("table1", true) as XRTable;   List<XRControl> controls = SerializeComponents(new List<XRControl>() { table }).ToList();   XRTable table1 = controls[0] as XRTable; }   IEnumerable<XRControl> SerializeComponents(IEnumerable<XRControl> components) { MemoryStream ms = new MemoryStream(); IRootXmlObject rootObject = new RootXmlObject(components); XRControlXmlSerializer serializer = new XRControlXmlSerializer(new XtraReportsSerializationContext() { RootObject = rootObject }); serializer.SerializeRootObject(rootObject, ms); ms.Position = 0; RootXmlObject newRoot = new RootXmlObject(); serializer.DeserializeObject(newRoot, ms, string.Empty); List<XRControl> list = new List<IComponent>(newRoot.Controls).Cast<XRControl>().ToList(); return list; }

                                I should note that the provided solution contains internal methods so that we cannot guarantee that this approach will work correctly in the future releases of our controls.

                                Thanks,
                                Elliot

                                • Customer91543 09.25.2019

                                  I works well.

                                  Thank you very much.
                                  Regards.