2025-01-29 04:40:14 +04:00
|
|
|
|
using Library36.Models;
|
|
|
|
|
using Library36;
|
|
|
|
|
|
2024-12-16 11:28:31 +04:00
|
|
|
|
namespace Test
|
|
|
|
|
{
|
|
|
|
|
public partial class FormTest : Form
|
|
|
|
|
{
|
|
|
|
|
private bool EmptyFill = false;
|
|
|
|
|
readonly List<Student> students = new()
|
|
|
|
|
{
|
|
|
|
|
new Student { Id = 0, Surname = "Elatomtsev", Height = 195, Iq = 155 },
|
|
|
|
|
new Student { Id = 1, Surname = "Bakshaeva", Height = 150, Iq = 170 },
|
|
|
|
|
new Student { Id = 2, Surname = "Firsov", Height = 180, Iq = 100 },
|
|
|
|
|
new Student { Id = 3, Surname = "Razin", Height = 185, Iq = 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 FormTest()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
CreateList();
|
|
|
|
|
}
|
|
|
|
|
private void CustomListBox1_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show($"Selected item: {customListBox1.SelectedValue}");
|
|
|
|
|
}
|
|
|
|
|
private void CreateList()
|
|
|
|
|
{
|
|
|
|
|
customListBox1.PopulateList(items);
|
|
|
|
|
}
|
|
|
|
|
private void buttonClear_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
customListBox1.ClearList();
|
|
|
|
|
}
|
|
|
|
|
private void buttonLoad_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CreateList();
|
|
|
|
|
customListBox1.Refresh();
|
|
|
|
|
}
|
|
|
|
|
private void buttonGetList_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string selectedValue = customListBox1.SelectedValue;
|
|
|
|
|
MessageBox.Show($"Selected Value: {selectedValue}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void CreateTable()
|
|
|
|
|
{
|
|
|
|
|
customDataGridView1.ConfigColumn(new()
|
|
|
|
|
{
|
|
|
|
|
ColumnsCount = 4,
|
|
|
|
|
NameColumn = new string[] { "Id", "Surname", "Height", "Iq" },
|
|
|
|
|
Width = new int[] { 10, 150, 250, 200 },
|
|
|
|
|
Visible = new bool[] { false, true, true, true },
|
|
|
|
|
PropertiesObject = new string[] { "Id", "Surname", "Height", "Iq" },
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
foreach (Student student in students)
|
|
|
|
|
{
|
|
|
|
|
int rowIndex = customDataGridView1.Rows.Add();
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
{
|
|
|
|
|
customDataGridView1.AddItem(student, rowIndex, i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
Student selectedStudent = customDataGridView1.GetSelectedObjectInRow<Student>();
|
|
|
|
|
MessageBox.Show($"Selected Row Index: {customDataGridView1.SelectedRow}");
|
|
|
|
|
MessageBox.Show($"Selected Student: {selectedStudent}");
|
|
|
|
|
}
|
|
|
|
|
private void buttonAddOneRow_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Student newStudent = new Student { Id = 4, Surname = "New Student", Height = 185, Iq = 125 };
|
|
|
|
|
int rowIndex = customDataGridView1.Rows.Add();
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
{
|
|
|
|
|
customDataGridView1.AddItem(newStudent, rowIndex, i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonGetValueCheckBox_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show($"Value is {dateBoxWithNull1.Value}");
|
|
|
|
|
}
|
|
|
|
|
private void buttonSetDate_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(textBoxDate.Text))
|
|
|
|
|
{
|
|
|
|
|
dateBoxWithNull1.Value = null; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> null, <20><><EFBFBD><EFBFBD> textBox <20><><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
else if (DateTime.TryParse(textBoxDate.Text, out DateTime date))
|
|
|
|
|
{
|
|
|
|
|
dateBoxWithNull1.Value = date;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-01-29 04:40:14 +04:00
|
|
|
|
|
|
|
|
|
private void ButtonExcelTable_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
(sender as Control).BackColor = Color.White;
|
|
|
|
|
excelTable1.CreateDoc(new Library36.Models.TableConfig
|
|
|
|
|
{
|
|
|
|
|
FilePath = "table.xlsx",
|
|
|
|
|
Header = "Example",
|
|
|
|
|
Data = new List<string[,]>
|
|
|
|
|
{
|
|
|
|
|
new string[,] {
|
|
|
|
|
{ "1", "1", "1" },
|
|
|
|
|
{ "1", "2", "2" },
|
|
|
|
|
{ "1", "3", "3" }
|
|
|
|
|
},
|
|
|
|
|
new string[,] { { "\n",} },
|
|
|
|
|
new string[,] {
|
|
|
|
|
{ "2", "3", "3" },
|
|
|
|
|
{ "3", "4", "4" },
|
|
|
|
|
{ "4", "5", "5" },
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
(sender as Control).BackColor = Color.Green;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ButtonExcelCustomTable_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
(sender as Control).BackColor = Color.White;
|
|
|
|
|
excelCustomTable1.CreateDoc(new Library36.Models.TableWithHeaderConfig<Student>
|
|
|
|
|
{
|
|
|
|
|
FilePath = "customTable.xlsx",
|
|
|
|
|
Header = "Student",
|
|
|
|
|
ColumnsRowsWidth = new List<(int Column, int Row)> { (5, 5), (10, 5), (10, 0), (5, 0), (7, 0) },
|
|
|
|
|
Headers = new List<(int ColumnIndex, string Header, string PropertyName)>
|
|
|
|
|
{
|
|
|
|
|
(0, "Id", "Id"),
|
|
|
|
|
(1, "Surname", "Surname"),
|
|
|
|
|
(2, "Height", "Height"),
|
|
|
|
|
(3, "Iq", "Iq"),
|
|
|
|
|
},
|
|
|
|
|
Data = students,
|
|
|
|
|
});
|
|
|
|
|
(sender as Control).BackColor = Color.Green;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ButtonExcelGistogram_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
(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 4", rnd.Next()) };
|
|
|
|
|
excelGistogram1.CreateDoc(new ChartConfig
|
|
|
|
|
{
|
|
|
|
|
FilePath = "gistogram.xlsx",
|
|
|
|
|
Header = "Chart",
|
|
|
|
|
ChartTitle = "BarChart",
|
|
|
|
|
LegendLocation = Library36.Models.Location.Top,
|
|
|
|
|
Data = new Dictionary<string, List<(string Name, double Value)>>
|
|
|
|
|
{
|
|
|
|
|
{ "Series 1", list2d }
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
(sender as Control).BackColor = Color.Green;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-16 11:28:31 +04:00
|
|
|
|
}
|