PIbd-31_Razubaev_S_M_COP-10/WinForms/FormComponents.cs

81 lines
2.3 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using WinFormsLibrary;
using WinFormsLibrary.Object;
namespace WinForms
{
public partial class FormComponents : Form
{
List<string> list = new List<string>();
List<Client> clients = new List<Client>();
public FormComponents()
{
list = new List<string>();
list.AddRange(new string[] { "привет", "пока", "бб" });
Client client1 = new Client("Сергей", "нет", "Идиот", 3);
Client client2 = new Client("Давид", "да-11", "Гений", 1);
Client client3 = new Client("Руслан", "Асу", "Летальный", 4);
clients.Add(client1);
clients.Add(client2);
clients.Add(client3);
InitializeComponent();
dropDownList.LoadValues(new List<string>() { "чего", "забей", "пример" });
emailTextBox.Pattern = @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$";
listBoxValues.SetLayout("ФИО [FIO] Обзор [Review] Статус [Status] сумма [Sum]", "[", "]");
dropDownList.ValueChanged += CustomEventHandler;
}
private void CustomEventHandler(object sender, EventArgs e)
{
MessageBox.Show("Хрю");
}
private void buttonAdd_Click(object sender, EventArgs e)
{
dropDownList.LoadValues(list);
}
private void buttonInfo_Click(object sender, EventArgs e)
{
labelInfo.Text = dropDownList.Selected;
}
private void buttonClear_Click(object sender, EventArgs e)
{
dropDownList.Clear();
}
private void buttonSetExample_Click(object sender, EventArgs e)
{
if (textBoxExample.Text == String.Empty)
{
return;
}
emailTextBox.setExample(textBoxExample.Text);
}
private void buttonShow_Click(object sender, EventArgs e)
{
try
{
if (emailTextBox.TextBoxValue != null)
{
labelEmail.Text = emailTextBox.TextBoxValue;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void buttonShowItem_Click(object sender, EventArgs e)
{
string str = listBoxValues.GetObjectFromStr<Client>().FIO + " " + listBoxValues.GetObjectFromStr<Client>().Review + " " + listBoxValues.GetObjectFromStr<Client>().Status + " " + listBoxValues.GetObjectFromStr<Client>().Sum;
labelShowInput.Text = str;
}
private void buttonAddValues_Click(object sender, EventArgs e)
{
listBoxValues.AddInListBox<Client>(clients);
}
}
}