为什么这个按钮点击两下才有效果 C#.NET WINFORM程序
我是这么想的
有一个主FORM 叫做FORM1 然后点击FORM1的按钮会实例化FORM2 而且我需要一个返回 所以我用的FORM2.SHOWDIALOG方法
以下是FORM2中的完整代码
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 TEMP
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
string Str;
public string str
{
set { Str = value; }
get { return Str; }
}
private void button1_Click(object sender, EventArgs e)
{
Str = textBox1.Text;
button1.DialogResult = DialogResult.OK;
}
}
}
测试我是成功的 但是出现一个问题 当我FORM2中的按钮点击2下以后才会提交窗口
这很奇怪
按道理是提交以下既可 想了半天想不明白为什么会出现这样的结果 请各位大侠帮下
谢谢