Я СДАЛ
This commit is contained in:
parent
7cb9784d4f
commit
5ff2f7cce8
@ -1,18 +1,16 @@
|
||||
using VisualComponentsForm.Models;
|
||||
using VisualComponentsLib.SupportClass;
|
||||
|
||||
namespace VisualComponentsForm
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private int countCol = 4;
|
||||
private int numberObject;
|
||||
|
||||
private List<string> nameCol = new List<string> { "Íîìåð", "Èìÿ", "Ôàìèëèÿ", "Âîçðàñò" };
|
||||
private List<int> widthCol = new List<int> { 60, 60, 60, 60 };
|
||||
private List<bool> showCol = new List<bool> { true, true, true, true };
|
||||
private List<string> nameField = new List<string> { "Id", "Name", "Surname", "Age" };
|
||||
private List<People> peoples;
|
||||
|
||||
private List<DataGridViewInfoCol> info;
|
||||
|
||||
public FormMain()
|
||||
{
|
||||
numberObject = 0;
|
||||
@ -25,6 +23,14 @@ namespace VisualComponentsForm
|
||||
new People(3, "Íèêîëàé", "Ðàñïàåâ", 23)
|
||||
};
|
||||
|
||||
info = new List<DataGridViewInfoCol>
|
||||
{
|
||||
new DataGridViewInfoCol("Íîìåð", "Id", 60, true),
|
||||
new DataGridViewInfoCol("Èìÿ", "Name", 60, true),
|
||||
new DataGridViewInfoCol("Ôàìèëèÿ", "Surname", 60, true),
|
||||
new DataGridViewInfoCol("Âîçðàñò", "Age", 60, true)
|
||||
};
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
@ -63,7 +69,7 @@ namespace VisualComponentsForm
|
||||
|
||||
private void ButtonCreateColumns_Click(object sender, EventArgs e)
|
||||
{
|
||||
myDataGridView.AddHeader(countCol, nameCol, widthCol, showCol, nameField);
|
||||
myDataGridView.AddHeader(info);
|
||||
}
|
||||
|
||||
private void ButtonClearTable_Click(object sender, EventArgs e)
|
||||
|
36
VisualComponentsLib/Components/ComponentWord.Designer.cs
generated
Normal file
36
VisualComponentsLib/Components/ComponentWord.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace VisualComponentsLib.Components
|
||||
{
|
||||
partial class ComponentWord
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
25
VisualComponentsLib/Components/ComponentWord.cs
Normal file
25
VisualComponentsLib/Components/ComponentWord.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VisualComponentsLib.Components
|
||||
{
|
||||
public partial class ComponentWord : Component
|
||||
{
|
||||
public ComponentWord()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public ComponentWord(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using VisualComponentsLib.SupportClass;
|
||||
|
||||
namespace VisualComponentsLib
|
||||
{
|
||||
@ -41,17 +42,16 @@ namespace VisualComponentsLib
|
||||
}
|
||||
|
||||
//публичный метод создания заголовков таблицы
|
||||
public void AddHeader(int countCol, List<string> nameCol, List<int> widthCol,
|
||||
List<bool> showCol, List<string> nameField)
|
||||
public void AddHeader(List<DataGridViewInfoCol> elements)
|
||||
{
|
||||
for (int i = 0; i < countCol; i++)
|
||||
foreach (var elem in elements)
|
||||
{
|
||||
DataGridViewColumn textColumn = new DataGridViewColumn();
|
||||
|
||||
textColumn.Name = nameField[i];
|
||||
textColumn.HeaderText = nameCol[i];
|
||||
textColumn.Width = widthCol[i];
|
||||
textColumn.Visible = showCol[i];
|
||||
textColumn.Name = elem.HeaderName;
|
||||
textColumn.HeaderText = elem.Name;
|
||||
textColumn.Width = elem.Width;
|
||||
textColumn.Visible = elem.IsVisible;
|
||||
textColumn.CellTemplate = new DataGridViewTextBoxCell();
|
||||
|
||||
dataGridView.Columns.Add(textColumn);
|
||||
|
@ -33,12 +33,9 @@ namespace VisualComponentsLib
|
||||
|
||||
set
|
||||
{
|
||||
if(!CheckValue())
|
||||
{
|
||||
textBox.Text = null;
|
||||
}
|
||||
checkBox.Checked = !value.HasValue;
|
||||
|
||||
textBox.Text = value.ToString();
|
||||
textBox.Text = value?.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
27
VisualComponentsLib/SupportClass/DataGridViewInfoCol.cs
Normal file
27
VisualComponentsLib/SupportClass/DataGridViewInfoCol.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VisualComponentsLib.SupportClass
|
||||
{
|
||||
public class DataGridViewInfoCol
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public string HeaderName { get; set; }
|
||||
|
||||
public int Width { get; set; }
|
||||
|
||||
public bool IsVisible { get; set; }
|
||||
|
||||
public DataGridViewInfoCol(string name, string headerName, int width, bool isVisible)
|
||||
{
|
||||
Name = name;
|
||||
HeaderName = headerName;
|
||||
Width = width;
|
||||
IsVisible = isVisible;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user