How can I check whether a form exists from its type and if so access its properties?
Posted on 2007-07-23
I need to be able check all MDI children for a specific type of form, and then if I find it check its properties to see if they match a known specification - this is to be able to determine if the particular form and its data already exists - if so, bring it to the front, if not create it.
The reason for this requirement is that I have multiple use forms, so there could be multiple instances of a single form each of which could contain information about a range of different things and this is determined by properties such as EditID which contains the ID of the current record being edited. Others determine the table, and so on.
In Delphi this is pretty simple, because you can use GetPropInfo^ to access the form's properties, and you can pass the form type directly to the method. I can get the form type in C#:
Type type = Type.GetType("MyNamespace.MyForm");
I can also loop through the MDI children, but that is where my plan falls down...
Can anyone advise the best way to achieve this?