sri

sri

  • NA
  • 6
  • 0

Create Event handler for a form from another class file

Jul 19 2009 6:17 PM
Hi guys,

I have a class named AutoComplete and I have created a textbox form. I can access the text box by creating an instance of the form in AutoComplete class. But when I try to write event handler the code doesn't give error but it doesn't execute the event handler. When I included the event handler in Form class it worked fine.

TextboxForm form = new TextboxForm();
form.myTextBox.TextChanged += new EventHandler(myTextBox_TextChanged);    // doesn't work

private void myTextBox_TextChanged(object sender, EventArgs e)
{
    MessageBox.Show("Textbox working!!!");
}

I would appreciate if anyone can help me with this issue.

Thank you


Answers (4)