Form Instance Example

MajP

You've got your good things, and you've got mine.
Local time
Today, 11:16
Joined
May 21, 2018
Messages
9,988
For those who have never worked with multiple form instances, here is a good example of how multiple form instances can have utility. It shows you one way you can manage the instances externally by opening and closing them from using the multi select listbox. Usually you would use something like this to be able to view and compare different records (two or more invoices, purchase orders, lists, employees).
There are other ways to manage your instances as discussed here:

Employees.png


The list on the left lets you open or close a form instance.

This is from the Northwind database and I have been using this data and looking at the blurry bitmaps for close to 30 years. I am so familiar with this employee table, that I kind of felt I knew these people. I dropped the images into chat and asked it to clean them up. What I found interesting was that Chat seemed to make everyone younger, thinner, and better looking even though I just asked it to clean up the image, put them in business clothes, and add a neutral background. The only one I played with with here is Suyama and said to make him look like an MMA fighter. OK, I actually went down the AI rabbit hole and made myself a Northwind dream team making all the women beautiful and the men fit and handsome.

The referenced thread discusses an issue with forms not closing when you remove all pointers to an instance. Not saying it is not correct, but so far I have not seen a reproducible example demonstrating this problem. This example shows that simply removing the reference to the form held in the collection the form will close the form.
 

Attachments

I thought the claim being made (in #10) was that multi-instance forms could be supported without a Public Collection or similar to hold the form references. Maybe I read that wrong.
 
I thought the claim being made (in #10) was that multi-instance forms could be supported without a Public Collection or similar to hold the form references.
You can support it, but I would say you cannot really "manage" it. You can simply keep the instance open without an external means to hold the reference. To me "manage", means you have a way to reference one of the specific open instances. That is demonstrated here. I can close the instance from the form with the listbox (it is an example of managing it externally, not necessarily needed).
So #10 does not provide a means to close just the instance "Steve Buchanan" externally, because there is no way to reference that instance.
Closing may not be a good example since you can close from a button on the specific form. But if you had some other type of manipulation you would do then you may need an external way to reference it. Think the forms collection and how often you use that to refer to a specific open form.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom