469,647 Members | 1,745 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,647 developers. It's quick & easy.

Custom public events problem

I have a control with custom events, fired by events occured from inside the
control.
But I can not see those events in design time from Properties window.
What's wrong???
Following the code:

public class test: System.Windows.Forms.UserControl

{

public event TSClickEventHandler TSClick;

//regular implementation

private void tsPlay_Click(object sender, System.EventArgs e)

{

TSButton btn = (TSButton)sender;

// do something

TSClickArgs btn_arg = new TSClickArgs(btn);

TSClick(this,btn_arg);

}

}

public class TSClickArgs : EventArgs

{

private TSButton m_button;

public TSClickArgs(TSButton button)

{

m_button = button;

}
}

public delegate void TSClickEventHandler(object sender, TSClickArgs e);


Nov 15 '05 #1
4 1795
Hi Tamir,

It seems ok to me.
Are you sure that your are using the right assembly (in case the control is
not the part of target assembly)?

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Tamir Khason" <ta**********@tcon-NOSPAM.co.il> wrote in message
news:eD**************@tk2msftngp13.phx.gbl...
I have a control with custom events, fired by events occured from inside the control.
But I can not see those events in design time from Properties window.
What's wrong???
Following the code:

Nov 15 '05 #2
Yes, but it does not work...
Sometimes I recieve the error:
TSClick(this,btn_arg); // Object reference not set to an instance of an
object.

What can be a problem???

"Miha Markic" <miha at rthand com> wrote in message
news:eL**************@TK2MSFTNGP11.phx.gbl...
Hi Tamir,

It seems ok to me.
Are you sure that your are using the right assembly (in case the control is not the part of target assembly)?

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Tamir Khason" <ta**********@tcon-NOSPAM.co.il> wrote in message
news:eD**************@tk2msftngp13.phx.gbl...
I have a control with custom events, fired by events occured from inside

the
control.
But I can not see those events in design time from Properties window.
What's wrong???
Following the code:


Nov 15 '05 #3
Hi Tamir,

Before calling TSClick you have to check if there is any handler associated:
if (TSClick != null)
TSClick(this,btn_arg);

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Tamir Khason" <ta**********@tcon-NOSPAM.co.il> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Yes, but it does not work...
Sometimes I recieve the error:
TSClick(this,btn_arg); // Object reference not set to an instance of an
object.

What can be a problem???

"Miha Markic" <miha at rthand com> wrote in message
news:eL**************@TK2MSFTNGP11.phx.gbl...
Hi Tamir,

It seems ok to me.
Are you sure that your are using the right assembly (in case the control

is
not the part of target assembly)?

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Tamir Khason" <ta**********@tcon-NOSPAM.co.il> wrote in message
news:eD**************@tk2msftngp13.phx.gbl...
I have a control with custom events, fired by events occured from
inside the
control.
But I can not see those events in design time from Properties window.
What's wrong???
Following the code:



Nov 15 '05 #4

Hi Tamir,

To fire your TSClick event, you should first add an event handler to your
event chain, then you can fire it. Also, to avoid exception, you should
check if the event chain is empty before firing the event.
For more information about how to use event in C#, please refer to:
http://msdn.microsoft.com/library/de...us/csspec/html
/vclrfcsharpspec_10_7.asp

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Steve Amey | last post: by
8 posts views Thread by bryan | last post: by
reply views Thread by Datacop | last post: by
1 post views Thread by rn5a | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.