PIbd-33_Abazov_A.A._KOP_29/AbazovApp/AbazovAppView/FormTest.cs

96 lines
2.8 KiB
C#
Raw Normal View History

2023-09-19 22:32:09 +04:00
using AbazovViewComponents.Components;
2023-09-21 18:50:11 +04:00
using AbazovViewComponents.Exceptions;
2023-09-19 22:32:09 +04:00
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 AbazovAppView
{
public partial class FormTest : Form
{
public FormTest()
{
InitializeComponent();
}
private void buttonAdd_Click(object sender, EventArgs e)
{
Random random = new Random();
List<string> items = new List<string>();
for (int i = 0; i < 3; i++)
{
items.Add("item" + random.Next(0, 10000));
}
abazovCheckedListBox.addItems(items);
abazovCheckedListBox.selectedItem = items[1];
}
private void abazovCheckedListBox_SelectedItemChange(string obj)
{
MessageBox.Show(obj, "Select event");
}
private void buttonClear_Click(object sender, EventArgs e)
{
abazovCheckedListBox.clear();
}
private void buttonSelected_Click(object sender, EventArgs e)
{
MessageBox.Show(abazovCheckedListBox.selectedItem ?? "null", "By getter");
}
2023-09-21 18:50:11 +04:00
private void buttonBoundries_Click(object sender, EventArgs e)
{
abazovDatePicker.dateFrom = new DateTime(1970, 01, 01);
abazovDatePicker.dateTo = new DateTime(2010, 01, 01);
}
private void buttonSetDate_Click(object sender, EventArgs e)
{
var result = MessageBox.Show("Установить значение в границах?", "Выбор", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
abazovDatePicker.Value = new DateTime(2000, 01, 01);
}
else
{
abazovDatePicker.Value = new DateTime(1900, 01, 01);
}
}
private void abazovDatePicker_DateChange(object sender, EventArgs e)
{
MessageBox.Show("ok");
}
private void abazovDatePicker_DateChange(DateTime obj)
{
MessageBox.Show(obj.ToShortDateString(), "Date change event");
}
private void buttonGetDate_Click(object sender, EventArgs e)
{
try
{
DateTime date = abazovDatePicker.Value;
MessageBox.Show(date.ToString(), "Через свойство");
}
catch (DateBoundsNotSetException ex)
{
MessageBox.Show(ex.Message);
}
catch (DateOutOfBoundsException ex)
{
MessageBox.Show(ex.Message);
}
}
2023-09-19 22:32:09 +04:00
}
}