hi friends, i am new to .net programming.any one help me to write a chat application with custom events in C#.net windows programming.
i got this through delegates.but, i need to do this in custom events.
i wrote some code as follows.
first i taken a form, placed abutton. under that button i write the code to generate a form(form with containing two text boxes, 2 labels and a button.);
i.e., //button_click
Form2 f2=new Form2( );
i defined a delegate and and args class, publisher class as follows
//delegate in namespace scope
public delegate void DelegateHandler(MyArgs ma);
//a class MyArgs used to hold some arguments values
public class MyArgs : EventArgs
{
public string msg;
}
//a class used to raise an event i.e publisher
public class publisher
{
public event DelegateHandler MyEvent;
public void disp(MyArgs ma)
{
MyEvent(ma);
}
}
in second form i use the code as follows
publisher p; MyArgs ma;
//under Form_load
//i created instances of the above classes
p=new publisher( ); ma=new MyArgs( );
p.MyEvent+=new DelegateHandler(receive); //'receive' is an local method
p.disp(ma);
}
public void receive(MyArgs e)
{
txtRes.Text = e.msg;
}
//under button
ma.msg+=textSend.Text;
p.disp(ma);
textSend.Text = " ";
My Problem is : it is complied successfully but its wont displaying the expected result.
so any one help me what is the problem in displaying the message in more than one form of Form2 type.
awaiting to some one help.
Thanks and regards
Sanjay Reddy.T