.NET learning curve - Generic Sub-Forms

  • Thread starter Thread starter Truett1
  • Start date Start date
T

Truett1

Guest
Description of my request is more difficult than it should be, but, here goes:

(Yes, I was very strong in VB6, but, my .Net skills need some help)



I can only explain how I did this in VB6, and hope there's some way to play inside

the box that works equally well. But, for a generic description of the plan, I would

take 3 forms (frmAddress, frmPhone, frmEmail) and make a simple form for each.

All the controls would be placed on a picture box as it's parent.

Then, anywhere I wanted to allow a user to enter or update any of the data from those forms, I would use it. More clarification needed still. In some cases, it may be as a modal dialog that would pop-up until closed. Other times, I would just set the parent of the picture box to a parent picture box on another form. For instance on a main form, I could use a tree to navigate and when expanding to something with details of say a contact or company then the sub-form (parent picture box) would contain that contact or company detail, and inside there would be a picture box for each of the sub-forms (for lack of better term) for Address, Phone or Email information.

Please note, in my case, I'd written everything unbound. I didn't have to be constrained by the events of using bound data and was free to handle my own events. I wrote a generic function for "SaveFormData", and depending on success or failure would turn around and run "SetFormState" which would disable "Save" button, and set whatever controls to an "Unedited" state or "Data Changed/Dirty" state. Not that the quoted information is necessarily literal, just for literary understanding. But, the way the form was shown could also change, in that possibly it needed to look more like it was only for data entry, and sometimes it needed to show all Address related to a contact/company (1 at a time with combobox listing all types created for that entity - Home, Work, Mailing, etc., same for Phones and Emails). In my case, they all had a "Default" checkbox to indicate which to display first if looking up for existing contact/company.

Everything I've read on implementing this kind of thing in .Net seems to point to this NOT being the way to go. They suggest using User Controls for such things. But, I'm all about re-use, functionality, and generic implementations. Plus, say we're using a TreeView control to determine what is being displayed in a "sub-form", the same parent control (picture box, panel, etc.) could be used as the place holder for whichever form is being shown in that area. Granted, my example went even further with that form showing contact or company detail, and the contact or company detail having a parent picture box as the place holder for each of the other 3 forms needed.

Simply:

1) I want generic simple forms for small often used data.

2) I want to be able to re-use these forms anywhere needed throughout the application, by either showing the form or just the controls from the form in the same layout. (With some controls hidden or disabled as needed according to state or function.)

3) I want to keep all the logic on the form, so it's NOT dependent on the parent displaying the form - so that all related logic is related with the form.


I struggled to describe the scenario in a manner that could be understood - but, I hope that I was successful.

If data implementation is important to the answers, I'm currently using unbound methods in my programming via SQLDataReader to get my data, and executing vb.Net functions to execute Stored Procs to save new or update existing data.

Before I can polish any of my code, I have to learn enough to know the limitations in other areas, like form management and data sharing techniques. In VB6, I had a generic "SaveFormData" function that returned success/failure and would save the data from any of the forms in the application. It would take a few parms like "Form Name", "Table/View Name" and via a few constants and user defined types (now Structures, I think) would have all the information needed to handle my data save implementations and the specific proc(s) to use. And a similar technique for "GetFormData" which populated a form.

I do tend to be kind of a purist, in that I like to stay inside the box, and not go third party - didn't help when upgrading from VB6 to .Net, but, worked great going from VB3, 4, 5 & 6.

I know this can be done - but, some of my findings where pretty ugly in their suggested implementations either in implementation or in function during use - or, they broke too many rules - but, the hardest part is finding answers when you don't even know how to ask the question.

Continue reading...
 

Similar threads

Back
Top