How do i use Form.ShowDialog?
- by Daniel Lip
private void button2_Click(object sender, EventArgs e)
{
ChangeLink cl = new ChangeLink();
// Show testDialog as a modal dialog and determine if DialogResult = OK.
if (cl.ShowDialog() == DialogResult.OK)
{
// Read the contents of testDialog's TextBox.
// cl.AcceptButton.DialogResult = DialogResult.OK;
this.label4.Text = cl.textBox1Text;
}
else
{
this.label4.Text = "Cancelled";
}
cl.Dispose();
}
When i click the button i see the new Form and the textBox1 in the new Form and i can type in the textBox1 something but i dont see anywhere an OK or CANCEL buttons. Should i add them manualy in the new Form designer ? And how to use them then ?
This is the code in my new Form what i wanted to do is to type something in the new Form textBox1 and pass the text in the textBox1 to Form1 label4.
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 GatherLinks
{
public partial class ChangeLink : Form
{
public ChangeLink()
{
InitializeComponent();
}
public string textBox1Text
{
get
{
return textBox1Text = textBox1.Text;
}
set
{
}
}
}
}
So where are the OK and CANCEL buttons of the Form.ShowDialog ?