private void b_Click(object sender, EventArgs e) { myform f; Label l; l = new Label(); f = new myform(); f.Text = "User-clicked Form"; l.Text = "Modal Form created by Modal Form"; l.Dock = DockStyle.Fill; f.FormBorderStyle = FormBorderStyle.FixedDialog; f.Controls.Add(l); f.BackColor = Color.Plum; f.ShowDialog(); f.DisplayInfo(); MessageBox.Show("Past ShowDialog() inside ShowDialog", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void change_Name_conMenStr_1_Click(object sender, EventArgs e) { SplitContainer split = (SplitContainer)conMenu_Source; TableLayoutPanel tbl_lay = (TableLayoutPanel)split.Panel1.Controls[0]; Label label = (Label)tbl_lay.Controls[1]; myform temp_Form = new myform(); temp_Form.Text = "Name ändern"; temp_Form.Name = "change_Name"; temp_Form.Size = new Size(421, 132); temp_Form.Load += Sub_Form_1_Load; temp_Form.FormBorderStyle = FormBorderStyle.FixedSingle; TableLayoutPanel temp_tbl = new TableLayoutPanel(); temp_tbl.Location = new Point(3, 0); temp_tbl.Size = new Size(400, 90); temp_tbl.ColumnCount = 2; temp_tbl.Name = "Tbl_1"; temp_tbl.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); temp_tbl.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); temp_tbl.RowCount = 3; temp_tbl.RowStyles.Add(new RowStyle(SizeType.AutoSize, 40F)); temp_tbl.RowStyles.Add(new RowStyle(SizeType.AutoSize, 40F)); temp_tbl.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F)); temp_tbl.Controls.Add(new Button() { Text = "Übernehmen", Name = "Btn_Ok", Dock = DockStyle.Fill, Size = new Size(50, 20) }, 0, 2); temp_tbl.Controls.Add(new Button() { Text = "Abrechen", Name = "Btn_Cancel", Dock = DockStyle.Fill, Size = new Size(50, 20) }, 1, 2); temp_tbl.Controls.Add(new TextBox() { Text = label.Text, Name = "tBx_Name", Dock = DockStyle.Fill }, 0, 1); temp_tbl.Controls.Add(new Label() { Text = "Anzeigename", Name = "lbl_Name", Dock = DockStyle.Fill, TextAlign = ContentAlignment.MiddleCenter }, 0, 0); temp_tbl.Controls["lbl_Name"].Margin = new Padding(3, 3, 3, 0); temp_tbl.Controls["tBx_Name"].Margin = new Padding(3, 0, 3, 3); temp_tbl.Controls["Btn_Ok"].Click += sub_form_1_Btn_Ok_Click; temp_tbl.Controls["Btn_Cancel"].Click += sub_form_1_Btn_Cancel_Click; temp_tbl.SetColumnSpan(temp_tbl.Controls[3], 2); temp_tbl.SetColumnSpan(temp_tbl.Controls[2], 2); temp_tbl.Controls["tBx_Name"].KeyDown += Sub_Form_1_KeyDown; temp_Form.Controls.Add(temp_tbl); var result = temp_Form.ShowDialog(); if (result == DialogResult.OK) { label.Text = temp_Form.Return_Value1; Size Textsize = TextRenderer.MeasureText(label.Text, label.Font); split.Panel1MinSize = tbl_lay.Controls[0].Width + 6 + Textsize.Width; split.SplitterDistance = split.Panel1MinSize; } }
private void btnFood_Click(object sender, EventArgs e) { myform myform1 = new myform(); myform1.ShowDialog(); //showDialog방식은 Modal방식 }