StrataFrame Forum

VS Question - finding event in C# version

http://forum.strataframe.net/Topic8327.aspx

By Rafe Kemmis - 4/19/2007

Hi,



I am evaluating your framework and have run into a problem during the Populating the Business Object as the Form Loads

section of the winforms tutorial. This step has you place code inside the ParentFormLoading event of the SF Form. My issue is that in Visual Studio the interface is different when coding in C#. When I view code of the form I don't get the same information in the two drop-down boxes above the code.



What I'd like to figure out is where to go in in visual studio to access the ParentFormLoading event of the SF Form. It doesn't seem to be listed as an event on the Properties panel...



Thank you in advance for you help.
By Ivan George Borges - 4/19/2007

Hi Rafe.

I'm a VB.NET guy, but I expect you can get through this going to the CustomerMaintenance designer, there you can see the CustomerBO1 on the bottom. Right-Click on it. Then go to the Properties. Their you couble click the ParentFormLoading and it will take you straight to where you should type your code.

Hope it helps.

By Trent L. Taylor - 4/19/2007

Ivan is correct.  You can also double-click the business object as this it the BOs default event.  In C#, you can access all events by selecting the BO in the designer and then swapping over to the events view.  Below is a picture that may help.

You can then simply double-click the event you wish to handle and the designer will create a handler for you automatically.

By Rafe Kemmis - 4/20/2007

Thanks for the quick responses!



I found two ways of doing this. First, you can double-click on the BO class file and then find this event in the properties panel. This lets you put this code inside your BO CLASS definition.



The other way to put the code in is to double-click your SF form class and then on the Properties menu there is a drop-down box of all the SF Form Class' class members... your instance of the BO class being one of them. Selecting that BO instance from the drop-down menu will display its events in the properties panel where you can set the event handler for that instance's parentformloading event.



So in once case you're defining the event handler for all instances of your BO class, and in the other case you are defining it for the one instance of you BO class.



Where is the correct place to put this event code?
By Trent L. Taylor - 4/20/2007

Where is the correct place to put this event code?

It depends on what you are trying to do.  For example, if you want to handle the ParentFormLoading event and perform the same function of code every time for that business object, then you would want to place your handler code in the BO source file.  However, if this is a one time thing, then you would want to add your handle and code on the form, form example.  So it really depends on what you are trying to accomplish.

Due to the nature of events, we are actually planning on having a section in our May training class dedicated to the understanding of how events work and how to interact with events in an application development environment.  Events, as you know, are a great tool but many times are misunderstood and not used to the best advantage of the developer many times.  So we have added this to our schedule so that some of these questions can be answered.

By Rafe Kemmis - 4/20/2007

Trent L. Taylor (04/20/2007)
Where is the correct place to put this event code?




It depends on what you are trying to do. For example, if you want to handle the ParentFormLoading event and perform the same function of code every time for that business object, then you would want to place your handler code in the BO source file. However, if this is a one time thing, then you would want to add your handle and code on the form, form example. So it really depends on what you are trying to accomplish.



Due to the nature of events, we are actually planning on having a section in our May training class dedicated to the understanding of how events work and how to interact with events in an application development environment. Events, as you know, are a great tool but many times are misunderstood and not used to the best advantage of the developer many times. So we have added this to our schedule so that some of thesequestions can be answered.




Doh, If I would have waited until the Configuring Business Object Properties section, I could have answered my own questionHehe