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();
}
Po kliknięciu przycisku widzę nowy Formularz i tekstBox1 w nowym formularzu i mogę wpisać textBox1 coś, ale nie widzę nigdzie przycisku OK lub ANULUJ. Czy powinienem dodać je manualnie w nowym projektorze formularzy? I jak z nich korzystać?Jak korzystać z Form.ShowDialog?
To jest kod w moim nowym formularzu, co chciałem zrobić, to wpisać coś w nowym formularzu TextBox1 i przekazać tekst w textBox1 do 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
{
}
}
}
}
Więc gdzie są przyciski OK i CANCEL formularza.ShowDialog?