69 lines
2.4 KiB
C#
69 lines
2.4 KiB
C#
using Controls;
|
|
using Controls.Exceptions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Forms
|
|
{
|
|
public partial class FormMain : Form
|
|
{
|
|
public FormMain()
|
|
{
|
|
InitializeComponent();
|
|
customComboBox.ComboBoxItems.Add("aboba1");
|
|
customComboBox.ComboBoxItems.Add("aboba2");
|
|
customComboBox.SelectedItem = "aboba1";
|
|
|
|
customTextBoxNumber.NumPattern = @"^\+7\d{10}$";
|
|
|
|
customListBox.SetTemplateString("Имя: {FirstName}, Фамилия: {LastName}, Возраст: {Age}", "{", "}");
|
|
Person person1 = new Person { FirstName = "{Лена}", LastName = "{Пряникова}", Age = "{18}" };
|
|
Person person2 = new Person { FirstName = "{Сергей}", LastName = "{Конфеткович}", Age = "{20}" };
|
|
customListBox.FillProperty(person1, 0, "FirstName");
|
|
customListBox.FillProperty(person1, 0, "LastName");
|
|
customListBox.FillProperty(person1, 0, "Age");
|
|
|
|
customListBox.FillProperty(person2, 1, "FirstName");
|
|
customListBox.FillProperty(person2, 1, "LastName");
|
|
customListBox.FillProperty(person2, 1, "Age");
|
|
}
|
|
private void buttonValidate_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string phoneNumber = customTextBoxNumber.TextBoxNumber;
|
|
MessageBox.Show($"Введенный номер: {phoneNumber}");
|
|
}
|
|
catch (CustomNumberException ex)
|
|
{
|
|
MessageBox.Show($"Ошибка: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
private void buttonGetObject_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
Person selectedPerson = customListBox.GetObjectFromStr<Person>();
|
|
MessageBox.Show($"Ваш друг. Имя: {selectedPerson.FirstName}, Фамилия: {selectedPerson.LastName}, Возраст: {selectedPerson.Age}");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show($"Ошибка: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
private void buttonAdd_Click(object sender, EventArgs e)
|
|
{
|
|
customComboBox.ComboBoxItems.Add("abobaSECRET");
|
|
}
|
|
}
|
|
}
|