c# - Subscribe to event in dll from another application -


i've been looking on possible solution, none seem come close need. have windows form outputs class library (dll). reference dll console application , launch gui in dll. want able subscribe control event , ever code in console application. have no problem when want read or write properties in dll directly console app. example:

mydll.myclass myobj = new mydll.myclass(); myobj.textbox1.text = "hello world!"; 

however, subscribe textchanged event in dll , output new text console app. along lines of:

public void textbox1_textchaned(object sender, eventargs e) {     console.writeline(myobj.textbox1.text); } 

is there way subscribe directly event? or other event?

  1. set modifier of textbox1 public

  2. subscribe textchanged event:

    myobj.textbox1.textchanged += textbox1_textchaned;

the following code in console app works me. i'm referencing windows form application rather dll, don't think there should difference:

 class program   {     static windowsformsapplication1.form1 frm;     static void main(string[] args)     {       frm = new windowsformsapplication1.form1();       frm.textbox1.textchanged += textbox1_textchanged;       system.windows.forms.application.run(frm);      }     static void textbox1_textchanged(object sender, eventargs e)     {       console.writeline((frm.textbox1.text));     }   } 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -