102 lines
2.1 KiB
C#
102 lines
2.1 KiB
C#
using ShabComponentsLibrary;
|
|
using ShabComponentsLibrary.Exceptions;
|
|
|
|
namespace FormsTesting
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
|
|
InitializeSelectComponent();
|
|
InitializeInputComponent();
|
|
InitializeGridComponent();
|
|
}
|
|
|
|
private void InitializeSelectComponent()
|
|
{
|
|
SelectComponent.SetItems(new List<string>
|
|
{
|
|
"Çíà÷åíèå 1",
|
|
"Çíà÷åíèå 2",
|
|
"Çíà÷åíèå 3",
|
|
"Çíà÷åíèå 4",
|
|
"Çíà÷åíèå 5",
|
|
});
|
|
}
|
|
|
|
private void InitializeInputComponent()
|
|
{
|
|
InputComponent.IntValue = 1500;
|
|
}
|
|
|
|
private void InitializeGridComponent()
|
|
{
|
|
GridComponent.ConfigureColumns(new List<ColumnInfo>
|
|
{
|
|
new ColumnInfo("", 0, false, "Id"),
|
|
new ColumnInfo("Ôàìèëèÿ", 150, true, "LastName"),
|
|
new ColumnInfo("Èìÿ", 150, true, "FirstName"),
|
|
new ColumnInfo("Âîçðàñò", 100, true, "Age"),
|
|
});
|
|
|
|
List<TestPerson> Persons = new List<TestPerson>
|
|
{
|
|
new TestPerson(1, "Èâàí", "Èâàíîâ", 34),
|
|
new TestPerson(2, "Ïåòð", "Ïåòðîâ", 44),
|
|
new TestPerson(3, "Ñåðãåé", "Ñåðãååâ", 55),
|
|
new TestPerson(4, "Îëüãà", "Èâàíîâà", 34),
|
|
new TestPerson(5, "Òàòüÿíà", "Ïåòðîâà", 44),
|
|
};
|
|
|
|
GridComponent.InsertValues(Persons);
|
|
}
|
|
|
|
private void SelectComponent_ItemSelected(object sender, EventArgs e)
|
|
{
|
|
MessageBox.Show(SelectComponent.SelectedItem);
|
|
}
|
|
|
|
private void InputComponent_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void ClearListButton_Click(object sender, EventArgs e)
|
|
{
|
|
SelectComponent.ClearList();
|
|
}
|
|
|
|
private void ShowIntButton_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
int? Value = InputComponent.IntValue;
|
|
if (Value != null)
|
|
{
|
|
MessageBox.Show($"Ââåäåííîå ÷èñëî: {Value}");
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Çíà÷åíèå - null");
|
|
}
|
|
}
|
|
catch (MalformedIntegralException ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
catch (EmptyValueException ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void PrintObjectButton_Click(object sender, EventArgs e)
|
|
{
|
|
var Test = GridComponent.GetSelectedObject<TestPerson>();
|
|
MessageBox.Show(Test.ToString());
|
|
}
|
|
}
|
|
}
|