读书人

为啥在Form_Load事件中button3.Perfor

发布时间: 2013-02-24 17:58:57 作者: rapoo

为何在Form_Load事件中button3.PerformClick()无法进入方法内进行调试
已经为button3写了事件处理程序,然后在Form_Load事件中调用button3.PerformClick(),在调试的时候F11无法进入到button3_Click()中调试。但是如果在其他地方调用button3.PerformClick()时,是可以F11进入到button3_Click()中调试的。

请问这是为什么呢? Form_Load?button
[解决办法]

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ButtonClick
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
button1.PerformClick();
}

private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("OK!");
}
}
}

可以的,你什么地方写错了吧!

读书人网 >C#

热点推荐