C# C中的UserControl文本框验证#

C# C中的UserControl文本框验证#,c#,winforms,user-controls,textbox,dialog,C#,Winforms,User Controls,Textbox,Dialog,我有一个文本框用户控件。我为MaximumLength文本框创建了一个动态属性 public int MaximumLength { get; set; } private void txtLocl_KeyPress(object sender, KeyPressEventArgs e) { txtLocl.MaxLength = MaximumLength;//txtLocl is a Usercontrol Textbox.., //txtL

我有一个文本框用户控件。我为MaximumLength文本框创建了一个动态属性

public int MaximumLength { get; set; }

    private void txtLocl_KeyPress(object sender, KeyPressEventArgs e)
    {
        txtLocl.MaxLength = MaximumLength;//txtLocl is a Usercontrol Textbox..,
        //txtLocl maxLength should be given by the user in WindowsForm
        //that should be come to here...,
    }
我在Windows窗体中显示UserControl属性的图像

现在我想验证用户何时更改该属性中的值


实现一个自定义设置器,用于检查值是否有效

public int MaximumLength
{
  get
  {
    return this.maximumLength;
  }

  set
  {
    if(value <= 4)
    {
      MessageBox.Show("Value is too small.");
    }
    else this.maximumLength = value;
  }
}
public int最大长度
{
得到
{
返回此.maximumLength;
}
设置
{

if(value)你的问题是什么?TabStop与验证有什么关系?TabStop只是该对话框的一个例子。我有一个usercontrol。它有一个动态创建的属性。最初我设置了一个值。现在我需要验证用户何时修改它。先生,它显示了一个错误,如get必须声明一个主体,因为它没有标记为抽象、外部和部分