ShowDialog()

  • Thread starter Thread starter Mohd Ebrahim
  • Start date Start date
M

Mohd Ebrahim

Hello,

In the below code , I want to launch all the 5 instances of 'frmCustomer'
but since its 'ShowDialog' i cant do it.

any way of achieving this?


int i=5;
while i < 5
{
using (frmCustomer obj = new frmCustomer())
{
obj.ShowDialog();
i++;
}
}

Regards,
 
Hi,

A modal dialog(that is the result of ShowDialog()) is a window that should
prevent user from doing anything else in an application, until the dialog is
closed. This means You should not have more than one modal dialog at any
time open in your application. (the ShowDialog blocks until the given form
is closed, so that is while the others wont be shown until that.)
In contrast modeless dialogs should not block the user from carrying on with
other parts of the application, meaning that more than one modeless dialogs
can be open at a given time. To show a form as modeless dialog You can use
the Show() method.

Hope You find this useful.
-Zsolt
 
Hello,

I have a MDI application. On load, i want to display these forms. I use
mdiTabbedChildren (not classic mdi child)

how can I use 'Show()' method and display all the forms as classic
childForms still visible in MDI container?

Thanks.
 
Hi,

MdiTabbedChildren control is third party control from Infragistics. each
child form will be added as a tab like 'internet explorer'. because when i
set the mdiParent=mditabbedControl then it will be added as a tab and not as
a 'classic mdi child'.

How can I show 'classic mdi form' within the mdi control (microsoft or any
third party)?

Regards,
 
Hi,

Basically You need a parent form, which has the IsMdiContainer property set
to true. This will be the main window, the MDI parent.
Then You can add child forms, by setting the child forms MdiParent property
to the parent form, and then calling Show on it.
Heres an example :

static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new ParentForm());
}
}

class ParentForm : Form
{
public ParentForm()
{
IsMdiContainer = true;
Width = Height = 600;
Text = "Parent form";
Load += new EventHandler(ParentForm_Load);
}

void ParentForm_Load(object sender, EventArgs e)
{
for (int i = 0; i < 5; i++)
{
ChildForm cf = new ChildForm();
cf.MdiParent = this;
cf.Show();
}
}
}

class ChildForm : Form
{
public ChildForm()
{
Text = "Child form";
}
}

Hope You find this useful.
-Zsolt
 
Back
Top