Example of how to use a base form


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (2.7K 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 (387 views, 222.00 KB)
Keith Chisarik
Keith Chisarik
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: StrataFrame Users
Posts: 939, Visits: 40K
I would love to download this, thanks Greg.

When I click the link to download I am just taken back to the main forum listing page, right click and save as gives a .html page. I have tried in IE and Firefox.

I have had this issue with attachments for a while now. Help appreciated.

Keith Chisarik

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (2.7K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Hmmm....that is weird. I have no problem with the attachment. Anyone else? Maybe its a setting in IE/firefox or a proxy issue?
Teddy Jensen
Teddy Jensen
StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)
Group: StrataFrame Users
Posts: 52, Visits: 8K
I have downloaded the attachment with IE without any problems.

And Greg - it is a very good sample with some functionality that i can use in my current application.

Thx.

Teddy

Richard Keller
Richard Keller
StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)StrataFrame Novice (104 reputation)
Group: Forum Members
Posts: 84, Visits: 324
For those who may not know.  You can get tricky and add it to the New Item dialog as well via Templates as well.   Just search VSTemplates or look in C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ItemTemplates\  for some samples.

Richard

Keith Chisarik
Keith Chisarik
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: StrataFrame Users
Posts: 939, Visits: 40K
I was able to download from home, thanks Greg.

Keith Chisarik
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hey Greg.

Very nice!

Thanks. Wink

Michael Reese
Michael Reese
StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)
Group: StrataFrame Users
Posts: 235, Visits: 1.6K
I got it. Make sure you are logged in before downloading!
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (2.7K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Glad it turned out that simple of a problem!
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