472,354 Members | 2,227 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

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 1857
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Steve Amey | last post by:
Hi all I am creating a basic control to perform some tasks, and I want to declare some events to be raised so they can be handled from the form that the control is on. I can create my own Event...
6
by: Christian H | last post by:
Hi! I've created a custom control (myDrawControl) that deals with drawing. This control is then added to a form( myMainForm) Now, whenever something is dragged and dropped onto myDrawControl ,...
5
by: | last post by:
I am wondering what the best method of attaching custom Events to custom WebUserControls are. I cannot seem to find the proper terminology to expand my research. Basicallly I have a custom user...
1
by: Martin | last post by:
Hi, I have produced a custom server control that simple outputs a row of 26 buttons, one button for each letter of the english alphabet. now what I would like to do is catch the button click...
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
8
by: bryan | last post by:
I've got a custom HttpHandler to process all requests for a given extension. It gets invoked OK, but if I try to do a Server.Transfer I get an HttpException. A Response.Redirect works, but I really...
0
by: Datacop | last post by:
I am making use of the Provider model to create custom logic providers for an in house winform application. I have my own provider consumer that is responsible for loading the proper provider...
1
by: rn5a | last post by:
I have created a custom control button which when clicked displays a message in the JavaScript alert dialog. I could successfully compile the VB class file into a DLL & also could add it to the...
0
by: sanjay02 | last post by:
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...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.