By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,920 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,920 IT Pros & Developers. It's quick & easy.

chat application in windows through custom events C#.NET

P: 1
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
Feb 7 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.