67 lines
1.5 KiB
C#

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 CustomComponents
{
public partial class frameTextBox : UserControl
{
private string? _text;
public frameTextBox()
{
InitializeComponent();
}
public string? Value
{
get
{
return _text;
}
set
{
_text = value;
}
}
private void CheckBoxStateChanged(object sender, EventArgs e)
{
if (ruleCheckBox.Checked)
{
textBox.Enabled = false;
if (!string.IsNullOrEmpty(_text))
{
MessageBox.Show("TextBox is not empty!");
}
}
else
{
textBox.Enabled = true;
if (string.IsNullOrEmpty(_text))
{
MessageBox.Show("TextBox is empty. You better write something!");
}
}
}
private void CheckTextBoxValueType(object sender, EventArgs args)
{
Value = textBox.Text;
try
{
Convert.ToInt32(Value);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}