日期:2014-05-17  浏览次数:20712 次

为何在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!");
        }
    }
}

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