0

In my UserControl i have a TextBox Which is not inheriting from TextBox, i am doing a

validation for Numerics (which allows only Digits)

public delegate void usercontrolError(string message);
    public event usercontrolError onerror;

 Private void txtLocl_KeyPress(object sender, KeyPressEventArgs e)
{
    if(e.KeyChar != '\b')
    {
        if(!char.IsDigit(e.KeyChar))
        {
        e.Handled=true;
        }
        else
       {
         onerror.Invoke("Enter Digits Only");
       }
    }
}

in Form i write the following code

 public Form1()
 {
     txtLocl.onerror += new ciscontrols.UserControl.usercontrolError(mtbDtTmPk1_onerror);
 }

    void UserControl_onerror(string message)
    {
        epfrm2.SetError(mtbDtTmPk1, message);
        //throw new NotImplementedException();
    }

i write the above code in Form. now i don't want to write any code in Form. But errorProvider is in Form1 only. How can i do Know. User cann't write any code in Form1.But Form ErrorProvider will work.

sree aneev
  • 141
  • 4
  • 5
  • 18
  • Could you please explain clearly what you want to achive?I could not understand it. – nsconnector Mar 08 '13 at 10:49
  • Call the error provider, using your code, if something is wrong, then call it. – Max Mar 08 '13 at 11:14
  • i am using a textbox UserControl. I want to show an errorProvider When user enter wrong. Now I am passing my error message through an event. In Form i create an Event Handler and Sending through a errorprovider. Now i don't want to write the Code in Form – sree aneev Mar 08 '13 at 11:15

0 Answers0