69 lines
2.6 KiB
C#
69 lines
2.6 KiB
C#
namespace WinForms
|
|
{
|
|
public partial class FormTest : Form
|
|
{
|
|
public FormTest()
|
|
{
|
|
InitializeComponent();
|
|
comboBoxControl.AddItems(new List<string> { "Çíà÷åíèå 1", "Çíà÷åíèå 2", "Çíà÷åíèå 3", "Çíà÷åíèå 4", "Çíà÷åíèå 5" });
|
|
|
|
textBoxControl.Pattern = @"^[a-z0-9._%+-]+\@([a-z0-9-]+\.)+[a-z]{2,4}$";
|
|
textBoxControl.SetTooltipText("example@gmail.com");
|
|
|
|
listBoxControl.SetParams("Èìÿ: {FirstName}, ôàìèëèÿ: {LastName}. {Gender} ({Age}) ëåò.", '{', '}');
|
|
listBoxControl.AddItems(new List<Person> { new() { FirstName = "Êèðèëë", LastName = "Ïåòðîâ", Age = 23, Gender = "ìóæ" },
|
|
new() { FirstName = "Ìàðèÿ", LastName = "Èâàíîâà", Age = 18, Gender = "æåí" },
|
|
new() { FirstName = "Åâà", LastName = "Ïàíôèëîâà", Age = 40, Gender = "æåí" } });
|
|
}
|
|
|
|
private void ButtonClear_Click(object sender, EventArgs e)
|
|
{
|
|
comboBoxControl.Clear();
|
|
}
|
|
|
|
private void ButtonGetComboBox_Click(object sender, EventArgs e)
|
|
{
|
|
MessageBox.Show(comboBoxControl.SelectedValue, "Ïîëó÷åííîå çíà÷åíèå");
|
|
}
|
|
|
|
private void ButtonSetComboBox_Click(object sender, EventArgs e)
|
|
{
|
|
comboBoxControl.SelectedValue = "Çíà÷åíèå 3";
|
|
}
|
|
|
|
private void ButtonGetTextBox_Click(object sender, EventArgs e)
|
|
{
|
|
MessageBox.Show(textBoxControl.Value, "Ïîëó÷åííîå çíà÷åíèå");
|
|
}
|
|
|
|
private void ButtonSetTextBox_Click(object sender, EventArgs e)
|
|
{
|
|
textBoxControl.Value = "forum98761@gmail.com";
|
|
}
|
|
|
|
private void ButtonSetWrongTextBox_Click(object sender, EventArgs e)
|
|
{
|
|
textBoxControl.Value = "smth";
|
|
}
|
|
|
|
private void ButtonGetObject_Click(object sender, EventArgs e)
|
|
{
|
|
Person? selectedPerson = listBoxControl.GetObject<Person>();
|
|
if (selectedPerson == null)
|
|
MessageBox.Show("Îáüåêò ïóñòîé");
|
|
MessageBox.Show($"Èìÿ: {selectedPerson?.FirstName}, Ôàìèëèÿ: {selectedPerson?.LastName}, " +
|
|
$"Âîçðàñò: {selectedPerson?.Age}, Ïîë: {selectedPerson?.Gender}");
|
|
}
|
|
|
|
private void ButtonGetIndex_Click(object sender, EventArgs e)
|
|
{
|
|
MessageBox.Show(listBoxControl.SelectedIndex.ToString(), "Ïîëó÷åííîå çíà÷åíèå");
|
|
}
|
|
|
|
private void ButtonSetIndex_Click(object sender, EventArgs e)
|
|
{
|
|
listBoxControl.SelectedIndex = 0;
|
|
}
|
|
}
|
|
}
|