From cefc5fcbe3a3120c27fb6741edbb843275e0ac2a Mon Sep 17 00:00:00 2001 From: frog24 Date: Tue, 22 Oct 2024 16:33:42 +0400 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=20=D1=87=D1=82=D0=BE?= =?UTF-8?q?=D0=B1=D1=8B=20=D0=BD=D0=B5=20=D0=BE=D0=B1=D1=8F=D0=B7=D0=B0?= =?UTF-8?q?=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE=20=D0=B2=D1=81=D0=B5=20?= =?UTF-8?q?=D1=81=D0=B2=D0=BE=D0=B9=D1=81=D1=82=D0=B2=D0=B0=20=D0=BF=D0=B8?= =?UTF-8?q?=D1=81=D0=B0=D1=82=D1=8C=20=D0=9A=D0=9E=D0=9C=D0=90=D0=9D=D0=94?= =?UTF-8?q?=D0=9D=D0=90=D0=AF=20=D0=A0=D0=90=D0=91=D0=9E=D0=A2=D0=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Components/NotVisualComponents/PdfTable.cs | 29 +++++++++++----------- CustomComboBox/TestApp/Form1.cs | 4 +-- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Components/NotVisualComponents/PdfTable.cs b/Components/NotVisualComponents/PdfTable.cs index 45eb867..481023d 100644 --- a/Components/NotVisualComponents/PdfTable.cs +++ b/Components/NotVisualComponents/PdfTable.cs @@ -115,30 +115,31 @@ namespace BarsukovComponents.NotVisualComponents foreach (var item in data) { var properties = item.GetType().GetProperties(); - if (properties.Count() != cellsCount) - { - throw new Exception("Кол-во полей объекта не совпадает с кол-вом колонок"); - } + //if (properties.Count() != cellsCount) + //{ + // throw new Exception("Кол-во полей объекта не совпадает с кол-вом колонок"); + //} - for (int i = 0; i < properties.Count(); i++) + + + + for (int i = 0; i < cellsCount; i++) { - var property = properties[i]; - var propValue = property.GetValue(item); - if (propValue == null) - { - throw new Exception("Пустое поле"); - } - if (property.Name == colInfo[i].PropertyName) + var property = properties.FirstOrDefault(p => p.Name == colInfo[i].PropertyName); + if (property != null) { + var propValue = property.GetValue(item); + if (propValue == null) + { + throw new Exception("Пустое поле"); + } if (table.Rows.Count <= rowData) { table.AddRow(); } table.Rows[rowData].Cells[i].AddParagraph(propValue.ToString()); - continue; } } - rowData++; } var renderer = new PdfDocumentRenderer(true); diff --git a/CustomComboBox/TestApp/Form1.cs b/CustomComboBox/TestApp/Form1.cs index d984078..11d52b5 100644 --- a/CustomComboBox/TestApp/Form1.cs +++ b/CustomComboBox/TestApp/Form1.cs @@ -115,13 +115,13 @@ namespace TestApp { new ColumnInfo("First","First Prop",50), new ColumnInfo("Second","Second Prop",100), - new ColumnInfo("Third","Third Prop",100), + //new ColumnInfo("Third","Third Prop",100), new ColumnInfo("Fourth","Fourth Prop",200), new ColumnInfo("Fifth","Fifth Prop",50), }; List mergeCells = new List() { - new MergeCells("Merged columns", new int[] {3,4}) + new MergeCells("Merged columns", new int[] {2,3}) }; List workers = new List() {