Programmable Physics
Member
- Joined
- Sep 26, 2022
- Messages
- 16
- Programming Experience
- 1-3
I have a form application that when clicking a menustrip button, it opens an instance of a form. I made this newly opened form a child of other form to make the newly opened form(child) to stay in the borders of this(parent) form.
I used
"Form that is not a top-level form cannot be displayed as a modal dialog box. Remove the form from any parent form before calling showDialog. "
How can I solve this?
I used
form.MdiParent
so newly opened form has a parent. If I try to use form.ShowDialog()
, rather than form.Show()
, it gives an error and says that"Form that is not a top-level form cannot be displayed as a modal dialog box. Remove the form from any parent form before calling showDialog. "
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ODEVCollectionListWinFormsUygulama
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
public List<string> musteriler1 = new List<string>();
private void müşteriGirişiToolStripMenuItem_Click(object sender, EventArgs e)
{
Form3 form3 = new Form3(musteriler1);
form3.MdiParent = this;
form3.Show();
}
private void müşteriListelemeToolStripMenuItem_Click(object sender, EventArgs e)
{
Form4 form4 = new Form4(musteriler1);
form4.MdiParent = this;
form4.Show();
}
}
}
Last edited: