Example of how to use a base form


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
This is an example of how to sub class the SF StandardForm to add functionality beyond what SF provides. I'm providing an example of some functionality that I needed, but of course, you may need vastly different features. Hopefully this might help in figuring out an elegant and pragmatic solution for you also!



I found myself very often coding the following features into a form:



- setting the title of the form to reflect the current record

- constructors that took the ID of a record that was passed to it, then loaded that single record into the form's BO.

- constructors that took a boolean that indicated I wanted to add a new record when the form opens.



I also need the ability to pass in a BO or data table with the data the form would use.



After doing this a few too many times, the light bulb went off and I realized there must be a better way. I then started to investigate how to use a base form. SF provided the example. The StandardForm inherits the SF BaseForm, which in turn provides all the SF niceness that we love. Why couldn't I do that myself and add my extra features? BigGrin



So, I coded a base form that added the features mentioned. Now when I need one or more of those features, I just inherit from my base form (which inherits from StandardForm...so I have the SF features too).



When the solution opens, an explanation page is shown that should help you get started.



For a savvy .NET developer, this is pretty basic stuff. However, a lot of us are moving from some other language/paradigm. So I thought I'd offer this up, as it might help to have a practical example of using a base class (plus some generic shared factory methods, how to hook into the SF events (see the OnLoad method)).



Of course, all of you savvy, svelte .NET gurus out there could certainly pipe in with suggestions for improvements or trade offs of doing things differently...I'm always learning more!



Thanks!

Greg Cool



P.S. You'll need the StrataFrameSample db loaded for this to work.
Attachments
BaseFormExample.zip (445 views, 222.00 KB)
Reply
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hey Greg.

Very nice!

Thanks. Wink

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search