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();
}
Quando faccio clic sul pulsante vedo il nuovo Form e il textBox1 nel nuovo Form e posso digitare nel testoBox1 qualcosa, ma non vedo da nessuna parte i pulsanti OK o CANCEL. Dovrei aggiungerli manualmente nel nuovo designer di moduli? E come usarli allora?Come si usa Form.ShowDialog?
Questo è il codice nel mio nuovo modulo quello che volevo fare è digitare qualcosa nel nuovo modulo TextBox1 e passare il testo nel textBox1 a 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
{
}
}
}
}
Quindi dove sono i pulsanti OK e CANCEL del Form.ShowDialog?