?
Solved

Opening a form and running a sub - can it also be dialog?

Posted on 2006-11-16
8
Medium Priority
?
179 Views
Last Modified: 2010-04-23
hi there

I would like to open a form as a dialog form.  However I also need to call a sub on the opened form (I call the same form in a lot of places so the sub I am running is important, and I load child forms onto the loaded form) i.e.

dim f as form1
f.showdialog()
f.getresults(id, date)

obviously f.getresults(id, date) wouldn't be called, but I do want the characteristics of the dialog in that I don't want the user to be able to move away from the form until it is closed.

Can I have the best of both worlds somehow?
0
Comment
Question by:DavidGreenfield
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 10

Expert Comment

by:Kinger247
ID: 17956285
Is there no reason why you cannot do it this way ?

f.getresults(id, date)
f.showdialog()
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17956439
a proper way of doing it would be handling the dialog close event from form1 and get the values there:

dim f as form1
AddHandler f.FormClosing, AddressOf f_closing
f.ShowDialog()


    Private Sub f_closing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs)
        Dim f As Form1 = DirectCast(sender, Form1)

        somevar = f.getresults(id, date)

    End Sub
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17956443
excuse me not from form1, i meant from the form that calls the form1
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:DavidGreenfield
ID: 17956522

Yes it is a little bit more compilcated that I have explained.

I have a generic "pop up" form with all the graphics in.  and I call a sub in this to load any form I want.

Sometimes the form I am loading needs to run a sub, where I tell the pop up not to load as dialog so I am able to do this.  What I really want is either to be able to switch the dialog on, or to mimick the dialog action.

so actually:

dim f as form1
popup.load(f,false) - where false means no dialog
f.getresults(id, date)
0
 
LVL 13

Accepted Solution

by:
newyuppie earned 2000 total points
ID: 17956523
what i posted is the proper way if you need to retrieve values, obviously when displayed dialog has started to close, and still has the variables in memory.
if you need to run a sub when the form is loading you can pretty much hook to any event in the dialog.

dim f as form1
AddHandler f.Load, AddressOf f_load
f.ShowDialog()

etc
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17956557
maybe write your own Show sub, so inside the dialog you could have something like:
public shared sub MyShow(byval boolDialog as boolean)
  dim f as new form1
  if boolDialog then
    f.showdialog
  else
    f.show
  end if
end sub

and call from your popup
f.MyShow(true) or f.MyShow(false)
0
 

Author Comment

by:DavidGreenfield
ID: 17956982
hi newyuppie,

your method does work, I had to change my code slightly - but it is now working.

Thank you very much!
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17957010
you're welcome, thanks for the points
NY
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month14 days, 14 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question