доделал компонент, чтобы работало без ошибок и по тз
This commit is contained in:
parent
3c1b43cb30
commit
7f404cadd4
1
COP/KryukovLib/CustomDataGridView.Designer.cs
generated
1
COP/KryukovLib/CustomDataGridView.Designer.cs
generated
@ -41,6 +41,7 @@
|
||||
dataGridViewItems.Name = "dataGridViewItems";
|
||||
dataGridViewItems.RowHeadersWidth = 51;
|
||||
dataGridViewItems.RowTemplate.Height = 29;
|
||||
dataGridViewItems.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewItems.Size = new Size(583, 353);
|
||||
dataGridViewItems.TabIndex = 0;
|
||||
//
|
||||
|
@ -57,28 +57,43 @@ namespace KryukovLib
|
||||
T val = new();
|
||||
|
||||
var propertiesObj = typeof(T).GetProperties();
|
||||
foreach (var properties in propertiesObj)
|
||||
foreach (var property in propertiesObj)
|
||||
{
|
||||
bool propIsExist = false;
|
||||
int columnIndex = 0;
|
||||
for (; columnIndex < dataGridViewItems.Columns.Count; columnIndex++)
|
||||
{
|
||||
if (dataGridViewItems.Columns[columnIndex].DataPropertyName.ToString() == properties.Name)
|
||||
if (dataGridViewItems.Columns[columnIndex].DataPropertyName.ToString() == property.Name)
|
||||
{
|
||||
propIsExist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (propIsExist)
|
||||
{
|
||||
object value = dataGridViewItems.SelectedRows[0].Cells[columnIndex].Value;
|
||||
properties.SetValue(val, Convert.ChangeType(value, properties?.PropertyType));
|
||||
};
|
||||
|
||||
Type propertyType = Nullable.GetUnderlyingType(property.PropertyType) ?? property.PropertyType;
|
||||
|
||||
if (value == null || value == DBNull.Value)
|
||||
{
|
||||
if (property.PropertyType.IsGenericType && property.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
|
||||
{
|
||||
property.SetValue(val, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
property.SetValue(val, Convert.ChangeType(value, propertyType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
public void AddItem<T>(T item, int RowIndex) where T : class
|
||||
{
|
||||
if (item == null)
|
||||
|
@ -153,6 +153,7 @@ namespace Test
|
||||
{
|
||||
(sender as Control).BackColor = Color.White;
|
||||
var rnd = new Random();
|
||||
var list2d = new List<(string Name, double value)>() { ("Series 2", rnd.Next()), ("Series 3", rnd.Next()), ("Series 52", rnd.Next()) };
|
||||
excelGistogram1.CreateDoc(new ChartConfig
|
||||
{
|
||||
FilePath = "bar.xlsx",
|
||||
@ -161,7 +162,7 @@ namespace Test
|
||||
LegendLocation = KryukovLib.Models.Location.Top,
|
||||
Data = new Dictionary<string, List<(string Name, double Value)>>
|
||||
{
|
||||
{ "Series 1", new() { ("Series 2", rnd.Next()), ("Series 3", rnd.Next()), ("Series 52", rnd.Next()) } }
|
||||
{ "Series 1", list2d }
|
||||
}
|
||||
});
|
||||
(sender as Control).BackColor = Color.Green;
|
||||
|
Loading…
Reference in New Issue
Block a user