【发布时间】:2012-09-08 18:34:06
【问题描述】:
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();
}
当我单击按钮时,我会看到新表单和新表单中的 textBox1。我可以在 textBox1 中输入一些东西,但是我在任何地方都看不到 OK 或 CANCEL 按钮。我应该在新的表单设计器中手动添加它们吗?那么如何使用它们呢?
这是我的新表单中的代码,我想做的是在新表单 textBox1 中输入一些内容并将 textBox1 中的文本传递给 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
{
}
}
}
}
那么 Form.ShowDialog 的 OK 和 CANCEL 按钮在哪里?
【问题讨论】:
标签: c#