سلام من یه یوزر کنترل درست کردم که از کلاس textBox ارثبری میکنه و کارش اینه که اجازه نده کاربر چیزی جز عدد وارد کنه تنها کد هایی که زدم اینه

 void DigitTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(char.IsDigit(e.KeyChar) || (int)e.KeyChar == 8 || e.KeyChar == '-'))
{
e.Handled = true;

PlayError();

return;
}
if ((int)e.KeyChar != 8)
{
if (SelectedText.Length > 0)
{
int startSelecting = SelectionStart;

string beforeErasingText, afterErasing;

beforeErasingText = SelectionStart > 0 ? Text.Substring(0, Text.Length - SelectionStart) : "";

afterErasing = Text.Substring(SelectionStart + SelectionLength,

Text.Length - (SelectionStart + SelectionLength));

if (long.Parse(beforeErasingText + e.KeyChar + afterErasing) > MaxValue)
{
e.Handled = true;

PlayError();

return;
}
}
else
{
if (long.Parse(Text + e.KeyChar) > MaxValue)
{
e.Handled = true;

PlayError();

return;
}
}
}

if ((SelectionLength == Text.Length || Text.Length == 1) && (int)e.KeyChar == 8)
{
e.Handled = true;

Text = "0";

SelectAll();
}
}

void DigiTextBox_TextChanged(object sender, EventArgs e)
{
Text = long.Parse(Text).ToString();

long TextValue = long.Parse(Text);

if ((TextValue > MaxValue))
{
Text = MaxValue.ToString();

SelectAll();

return;
}
if (TextValue < 0 && TextValue < -1 * TextValue)
{
Text = (-1 * MaxValue).ToString();

SelectAll();

return;
}
}
long _maxValue = 1000000000000000000;
public long MaxValue
{
get
{
return _maxValue;
}
set
{
_maxValue = value;
}
}


مشکل من اینجاست که ویژوال اصلا اجازه نمیده من اینو توی فرم اد کنم و این ارور رو میده

1.png
ممنون از راهنمایی هاتون