Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / February 2007

Tip: Looking for answers? Try searching our database.

MDI app - don't load document twice

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Elmo Watson - 10 Feb 2007 05:19 GMT
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)?
RobinS - 10 Feb 2007 06:58 GMT
How do you know if it has already been loaded?

Robin S.
-----------------------------
> 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 - 10 Feb 2007 16:49 GMT
> 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)?

what kind of file is that? or are you referring to an MDI child form?
Bob Powell [MVP] - 10 Feb 2007 21:37 GMT
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.

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.

> 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)?
Elmo Watson - 11 Feb 2007 01:42 GMT
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)?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.