Модальное диалоговое окно используется для обмена информацией с пользователем. Это окно не позволяет выполнить другую задачу в приложении, пока не будет выполнен ответ на запрос этого диалогового окна.
Для отображения модального диалогового окна используется метод ShowDialog().
Для отображения модального диалогового окна используется метод ShowDialog().
FormModal1.cs
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespace_0017 {-
publicpartialclassFormModal1 : Form { -
publicFormModal1() { -
InitializeComponent(); -
} -
privatevoidbutton1_Click(objectsender, EventArgs e) { -
label2.Text = textBox1.Text; -
} -
} }
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespace_0017 {-
publicpartialclassFormModal1 : Form { -
publicFormModal1() { -
InitializeComponent(); -
} -
privatevoidbutton1_Click(objectsender, EventArgs e) { -
label2.Text = textBox1.Text; -
} -
} }
FormModal2.cs
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;namespace_0017 {-
publicpartialclassFormModal2 : _0017.FormModal1 { -
publicFormModal2() { -
InitializeComponent(); -
} -
privatevoidbutton1_Click(objectsender, EventArgs e) { -
label2.Text = textBox1.Text; -
} -
} }
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;namespace_0017 {-
publicpartialclassFormModal2 : _0017.FormModal1 { -
publicFormModal2() { -
InitializeComponent(); -
} -
privatevoidbutton1_Click(objectsender, EventArgs e) { -
label2.Text = textBox1.Text; -
} -
} }
Form1.cs
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespace_0017 {-
publicpartialclassForm1 : Form { -
publicForm1() { -
InitializeComponent(); -
} -
privatevoidbutton1_Click(objectsender, EventArgs e) { -
FormModal1 FM1 =newFormModal1(); -
FM1.ShowDialog(); -
//или -
//new FormModal1().ShowDialog(); -
} -
privatevoidbutton2_Click(objectsender, EventArgs e) { -
newFormModal2().ShowDialog(); -
//или -
//FormModal1 FM2 = new FormModal2(); -
//FM2.ShowDialog(); -
} -
} }
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespace_0017 {-
publicpartialclassForm1 : Form { -
publicForm1() { -
InitializeComponent(); -
} -
privatevoidbutton1_Click(objectsender, EventArgs e) { -
FormModal1 FM1 =newFormModal1(); -
FM1.ShowDialog(); -
//или -
//new FormModal1().ShowDialog(); -
} -
privatevoidbutton2_Click(objectsender, EventArgs e) { -
newFormModal2().ShowDialog(); -
//или -
//FormModal1 FM2 = new FormModal2(); -
//FM2.ShowDialog(); -
} -
} }