none
How does a form know if it was opened with show() or showdialog()? RRS feed

  • Question

  • Hi,

    I'm not sure if this is the right forum but that's the closest I found.

    Anyway, my question is how do I know if my form is a dialog (opened by showdialog()) or opened with show()?

    Dror
    Saturday, February 6, 2010 2:01 PM

Answers

  • the first can't be True: you execute the line AFTER the frm closed.
    the second can't be True: the frm is not completely created
    the third is right :o))
    please, mark this as answer if it is THE answer
    ----------------
    Diego Cattaruzza
    Microsoft MVP - Visual Basic: Development
    blog: http://community.visual-basic.it/Diego
    web site: http://www.visual-basic.it
    • Marked as answer by SamAgain Friday, February 12, 2010 11:42 AM
    Saturday, February 6, 2010 5:14 PM

All replies

  • Hi,
    if it is a showdialog you can not access any other forms.
    show() you can access other forms.
    Best Regards, C.Gnanadurai ----------------------- Please mark the post as answer if it is helpfull to you
    Saturday, February 6, 2010 2:05 PM
  • get the form.Modal property
    please, mark this as answer if it is THE answer
    ----------------
    Diego Cattaruzza
    Microsoft MVP - Visual Basic: Development
    blog: http://community.visual-basic.it/Diego
    web site: http://www.visual-basic.it
    Saturday, February 6, 2010 3:13 PM
  • Thanks,

    I tried it it works fine - but as a note following would give false:

    Form1 frm = new Form1();
    frm.ShowDialog();
    MessageBox.Show(frm.Modal.ToString()); ///this shows false!

    In the constructor of Form1:

    MessageBox.Show(this.Modal.ToString()); //this shows false!

    but in an event of form1 - this.Modal.ToString()) ---> shows true.

    This is good enough but i'm just curious why the first two don't show true (the msdn exaple of Form.Modal implied the first should show true).

    I have another question: what is the best way to allow a form to appear only as a modal (showdialog()) form.

    Thanks,
    Dror

    Saturday, February 6, 2010 4:23 PM
  • the first can't be True: you execute the line AFTER the frm closed.
    the second can't be True: the frm is not completely created
    the third is right :o))
    please, mark this as answer if it is THE answer
    ----------------
    Diego Cattaruzza
    Microsoft MVP - Visual Basic: Development
    blog: http://community.visual-basic.it/Diego
    web site: http://www.visual-basic.it
    • Marked as answer by SamAgain Friday, February 12, 2010 11:42 AM
    Saturday, February 6, 2010 5:14 PM

  • Thanks, I got it now. But any idea on how to make a form appear only as a showdialog(), do i override the Show() method or something like that?

    Dror
    Sunday, February 7, 2010 5:48 PM