none
Form ShowDialog() RRS feed

  • Question

  • Hi,

    I have use Showdialog() method to view a Child form (FormB), when clicking a button of Parent Form(FormA).

    As usually After clicking the Button, FormB is appearing and FormA Blocked. 

    But Now i want to desapear FormB, when mouse click on the FormA(Parent), Because i dont need to close child all the time using the Controlbox. i need to desapear it when parent active.

    If you guys have any idea, plz reply.

    Thank u

    Friday, July 6, 2012 10:36 AM

Answers

  • hi can you share your code,

    and try to add an event onFormLeave and add script

    this.hide() or this.Close()


    By Sanz. -- If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".

    • Proposed as answer by san Sanz Friday, July 6, 2012 10:53 AM
    • Marked as answer by Tharaka Perera Thursday, July 12, 2012 10:21 AM
    Friday, July 6, 2012 10:53 AM

All replies

  • Use Show() method instead of ShowDialog()

    It all Happenz Sendil

    Friday, July 6, 2012 10:41 AM
  • use show() instead of showdialog()

    It all Happenz Sendil

    Friday, July 6, 2012 10:50 AM
  • hi can you share your code,

    and try to add an event onFormLeave and add script

    this.hide() or this.Close()


    By Sanz. -- If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".

    • Proposed as answer by san Sanz Friday, July 6, 2012 10:53 AM
    • Marked as answer by Tharaka Perera Thursday, July 12, 2012 10:21 AM
    Friday, July 6, 2012 10:53 AM
  • Hi,

    Use Show() method instead of the showDialog(). Show method does not make dependencies on the child form. But ShowDialog() indicates and create dependencies on the child screen to perform some operation and to close the child screen. Parent screen could be inactive until the child screen gets close , if showDialog() method use. Show() method is not good way . Because every time you clicking the button it creates new child form. but showdialog() method creates only one child.


    Manikandan Murugeshan


    Friday, July 6, 2012 11:03 AM
  • Here is a quick and dirty sample code I wrote up. I don't know if it is exactly what you are looking for, but hopefuly it points you in the right direction.

    Code:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                this.MouseEnter +=new EventHandler(Form1_Enter);
            }
            private Form2 frm2;
            private void Form1_Enter(object sender, EventArgs e)
            {
                if (frm2_check()) { frm2.Close(); }
            }
            private void button1_Click(object sender, EventArgs e)
            {
                if (!frm2_check())
                {
                    frm2 = new Form2();
                    frm2.Show();
                }
            }
            private Boolean frm2_check()
            {
                foreach (Form frm in Application.OpenForms)
                {
                    if (frm is Form2) { return true; }
                }
                return false;
            }
        }
    }

    Friday, July 6, 2012 11:27 AM