
Signature
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
OK - I understand that - but how do you do it ??
In vb6, you would iterate through the forms collection (For Each objForm In
Forms)
That's the first line - it got an error but didn't show me any of the
possible ways to change it...
> The standard response is not to nform the user but just to bring the
> already open file to the front or show it if it's hidden.
>
>> How can I (in VB.Net 2005) check (when loading a file), to make sure if
>> it's already been loaded - then prompt the user to see if they really
>> want to do it (since it's already been loaded)?
Leon Tayson - 11 Feb 2007 10:30 GMT
add this method in your MDI form class
private void ShowForm(Type formType)
{
foreach (Form child in this.MdiChildren)
{
//if (formType.Name == child.Name)
if (formType.IsInstanceOfType(child))
{
child.Focus();
return;
}
}
Form frm = (Form)Activator.CreateInstance(formType);
frm.MdiParent = this;
frm.Show();
}
you can show your child form using ShowForm(typeof(YourChildFormClass))
> OK - I understand that - but how do you do it ??
>
[quoted text clipped - 10 lines]
> >> it's already been loaded - then prompt the user to see if they really
> >> want to do it (since it's already been loaded)?
Bob Powell [MVP] - 11 Feb 2007 13:26 GMT
The simplest way is to rely on the naming scheme of the documents. For
example when loadin a file the document will be called by the filename or
possibly just it's file name without the extension.
When a file load attempt is made, check all your existing loaded documents
to see if one of the same name exists, if it does, show it, if it doesn't
continue with the load.

Signature
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
> OK - I understand that - but how do you do it ??
>
[quoted text clipped - 10 lines]
>>> it's already been loaded - then prompt the user to see if they really
>>> want to do it (since it's already been loaded)?
Elmo Watson - 18 Feb 2007 02:37 GMT
I've got a Property in my MDI form (DocName), which returns the ActiveMDI
file's document name (file loaded and showing in rtb). I'm still stumbling
around a bit
I'm using VB.Net (I couldn't translate from C# example given):
I've got :
the variable: 'filename' is the file I'm trying to load
Dim child as System.Windows.Forms.Form ' <-- don't know how to refer to the
DocName of each
For each Child in Me.MdiChildren
If CurrentForm.DocName = fileName Then ' <-- what do I need here, to
compare files?
blLoaded = True
Exit For
Else
blLoaded = False
End If
next
Can anyone help me finish here?
> The simplest way is to rely on the naming scheme of the documents. For
> example when loadin a file the document will be called by the filename or
[quoted text clipped - 18 lines]
>>>> it's already been loaded - then prompt the user to see if they really
>>>> want to do it (since it's already been loaded)?