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 / September 2004

Tip: Looking for answers? Try searching our database.

show dialog just after a form is shown

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
lukasz - 30 Aug 2004 17:07 GMT
Is there an equivalent of OnShow event for forms? I want to open a file open
dialog immediately after my form is shown (modelessly). OnLoad and
OnVisibleChanged do not suit me since it shows the file dialog before
showing my form. Any ideas?
Imran Koradia - 30 Aug 2004 18:39 GMT
try the Activated Event of the form. This is fired after the Load event when
the form is activated. Ofcourse, this is also fired when the form is
activated from an inactive state. So you'll probably need to check whether
its the first time Activated has been fired (after the Load).

hope this helps..
Imran.

> Is there an equivalent of OnShow event for forms? I want to open a file open
> dialog immediately after my form is shown (modelessly). OnLoad and
> OnVisibleChanged do not suit me since it shows the file dialog before
> showing my form. Any ideas?
Mark Broadbent - 01 Sep 2004 11:21 GMT
One way to do this is to use event delegates.
Create your procedure to show your dialog. Subscribe this to the event of
your choice (for this example I used the paint event) within the Form Load.
Within your procedure you should unsubscribe itself from the paint event so
that the dialog is only shown once.

as thus...
 private void FormLukazExample_Load(object sender, System.EventArgs e)
 {
  this.Paint +=new PaintEventHandler(OpenFileDialog);
 }

 private void OpenFileDialog(object sender, PaintEventArgs p)
 {
  this.Paint -= new PaintEventHandler(OpenFileDialog);
  System.Windows.Forms.OpenFileDialog dlg = new OpenFileDialog();
  if (dlg.ShowDialog() == DialogResult.OK)
  {
   //code
  }
 }

Hope this helps :)
Br,

Mark Broadbent.

> Is there an equivalent of OnShow event for forms? I want to open a file open
> dialog immediately after my form is shown (modelessly). OnLoad and
> OnVisibleChanged do not suit me since it shows the file dialog before
> showing my form. Any ideas?

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.