diff --git a/Components/CustomDataGridView.cs b/Components/CustomDataGridView.cs index 026e9d6..925f9a5 100644 --- a/Components/CustomDataGridView.cs +++ b/Components/CustomDataGridView.cs @@ -93,10 +93,20 @@ namespace Components var properties = typeof(T).GetProperties(); - foreach (var obj in objects) + for (int i = 0; i < objects.Count; ++i) { - var values = properties.Select(p => p.GetValue(obj, null)).ToArray(); - dataGridView.Rows.Add(values); + var row = objects[i]; + dataGridView.Rows.Add(); + + for (int j = 0; j < dataGridView.ColumnCount; ++j) + { + var property = properties.FirstOrDefault(p => p.Name == dataGridView.Columns[j].DataPropertyName); + + if (property != null) + { + dataGridView.Rows[i].Cells[j].Value = property.GetValue(row, null); + } + } } } } diff --git a/Components/CustomTextBox.cs b/Components/CustomTextBox.cs index 2ff1dfd..94529e7 100644 --- a/Components/CustomTextBox.cs +++ b/Components/CustomTextBox.cs @@ -45,16 +45,8 @@ namespace Components } set { - if (value.HasValue) - { - checkBoxNull.Checked = false; - textBoxInteger.Text = value.ToString(); - } - else - { - checkBoxNull.Checked = true; - textBoxInteger.Text = string.Empty; - } + checkBoxNull.Checked = !value.HasValue; + textBoxInteger.Text = value.HasValue ? value.ToString() : string.Empty; } }