Invoking public events of a control.... 
Author Message
 Invoking public events of a control....

Hello, I'm having trouble in implementing this.
How does one public event call other public event of the same
control??? What or how do I need to write the statement.

All I've done now is this:

Call TreeView1_BeforeExpand(Nothing, New System.EventArgs())

from the TreeView1_Click event.
But I get this error: An unhandled exception of type
'System.InvalidCastException' occurred in TreeLoad.exe

Additional information: Specified cast is not valid.

Dont know how to make it work.
Any information of how to do this will be very helpful.

Benz.



Tue, 01 Feb 2005 19:48:19 GMT  
 Invoking public events of a control....

Quote:
> Hello, I'm having trouble in implementing this.
> How does one public event call other public event of the same
> control??? What or how do I need to write the statement.

> All I've done now is this:

> Call TreeView1_BeforeExpand(Nothing, New System.EventArgs())

> from the TreeView1_Click event.
> But I get this error: An unhandled exception of type
> 'System.InvalidCastException' occurred in TreeLoad.exe

> Additional information: Specified cast is not valid.

> Dont know how to make it work.
> Any information of how to do this will be very helpful.

> Benz.

You don't call events, you raise them. If you want something to be done in
two different places, write a procedure that is called from those two
location. That means, don't write the code in the BeforeExpand event but in
a seperate sub. Call the sub in the event procedure and there where you
wrote your Call statement above.

TreeView1_BeforeExpand expects a
System.Windows.Forms.TreeViewCancelEventArgs object but you create a
System.EventArgs object. I wonder who it can compile at all.
The abstract procedure doesn't need a TreeViewCancelEventArgs argument
because it doesn't know that it's called from an event procedure. You should
pass the values you need to the abstract procedure. Which values depends on
it's purpose.

Yet, my first question should have been: What is the code in the error line?

Armin



Tue, 01 Feb 2005 20:57:19 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Mysterious invoke of CustomPropertyChange event

2. invoking an event on a different thread

3. Invoke/Call/Fire the Events Read/WriteProperties

4. PRB : Invoking an event treatment

5. invoke combobox click event?

6. Wired event handler never invoked...

7. How do I Invoke node click event?

8. Sheridan Grid OBJECT not invoking Events

9. PRB : Invoking an event treatment

10. Invoking event treatment

11. Control.Invoke without control?

12. Control Event Problem (Post Event after an event is fired)

 

 
Powered by phpBB® Forum Software