VisualComponents/VisualComponentsLib/UserTextBox.cs

62 lines
1.5 KiB
C#
Raw Normal View History

2023-09-13 11:57:01 +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 VisualComponentsLib
{
public partial class UserTextBox : UserControl
{
2023-09-13 12:53:53 +04:00
public string inputString
{
get => textBox.Text;
set => textBox.Text = value;
}
public new event EventHandler? TextChanged
{
add => textBox.Text = value.ToString();
remove => textBox.Text = string.Empty;
}
2023-09-13 11:57:01 +04:00
public UserTextBox()
{
InitializeComponent();
}
2023-09-13 12:53:53 +04:00
public void clickCheckBox()
{
if(checkBox.Checked)
{
textBox.ReadOnly = true;
inputString = string.Empty;
textBox.Text = string.Empty;
}
if(!checkBox.Checked)
{
try
{
double support;
if (Double.TryParse(textBox.Text, out support))
{
inputString = textBox.Text;
}
}
catch (Exception ex)
{
MessageBox.Show("Введённое значение не является вещественным числом.");
}
}
}
2023-09-13 11:57:01 +04:00
}
}