PIbd-31_Kryukov.A.I._COP_9/COP/Test/Form1.cs
Алексей Крюков 28ddf245dc lab_1
2024-09-22 10:42:52 +04:00

118 lines
3.3 KiB
C#

using KryukovLib;
using Microsoft.VisualBasic.Devices;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Header;
using static KryukovLib.CustomDataGridView;
namespace Test
{
public partial class Form1 : Form
{
private bool EmptyFill = false;
readonly List<Car> cars = new()
{
new Car { Id = 0, marka = "Nissan terrano", weight = 1300, maxSpeed = 155 },
new Car { Id = 1, marka = "Nissan X-Trail", weight = 1500, maxSpeed = 170 },
new Car { Id = 2, marka = "Zhigyl)", weight = 400, maxSpeed = 100 },
new Car { Id = 3, marka = "Chevrolet rezo", weight = 1200, maxSpeed = 140 },
};
readonly List<string> items = new()
{
new string("item1"),
new string("item2"),
new string("item3"),
new string("item4"),
new string("item5"),
new string("item6"),
new string("item7"),
};
public Form1()
{
InitializeComponent();
CreateList();
customListBox1.ValueChanged += CustomListBox1_ValueChanged;
}
private void CustomListBox1_ValueChanged(object sender, EventArgs e)
{
// Âûâîäèì âûáðàííîå çíà÷åíèå
MessageBox.Show($"Selected item: {customListBox1.SelectedValue}");
}
private void CreateList()
{
customListBox1.PopulateList(items);
}
private void CreateTable()
{
customDataGridView1.ConfigColumn(new()
{
ColumnsCount = 4,
NameColumn = new string[] { "Id", "marka", "weight", "maxSpeed" },
Width = new int[] { 10, 150, 250, 200 },
Visible = new bool[] { false, true, true, true },
PropertiesObject = new string[] { "Id", "marka", "weight", "maxSpeed" }
});
foreach (Car car in cars)
{
int rowIndex = customDataGridView1.Rows.Add();
for (int i = 0; i < 4; i++)
{
customDataGridView1.AddItem(car, rowIndex, i);
}
}
}
private void buttonClear_Click(object sender, EventArgs e)
{
customListBox1.ClearList();
}
private void buttonLoad_Click(object sender, EventArgs e)
{
CreateList();
customListBox1.Refresh();
}
private void buttonClearTable_Click(object sender, EventArgs e)
{
customDataGridView1.ClearDataGrid();
}
private void buttonTableAdd_Click(object sender, EventArgs e)
{
CreateTable();
}
private void buttonGetValue_Click(object sender, EventArgs e)
{
}
private void buttonGetValueCheckBox_Click(object sender, EventArgs e)
{
MessageBox.Show($"Value is {dateBoxWithNull1.Value}");
}
private void buttonSetValueCheckBox_Click(object sender, EventArgs e)
{
if (EmptyFill)
{
dateBoxWithNull1.Value = DateTime.Now;
}
else
{
dateBoxWithNull1.Value = null;
}
EmptyFill = !EmptyFill;
}
}
}