已有56人关注
C#从入门到精通第12章例12.6代码报错
发表在C#图书答疑 2016-06-03
是否精华
版块置顶:
C#从入门到精通 第12章例12.6实现关闭窗体前弹出提示框,按照书上代码,为什么会提示e.Cancel=falsed的
错误 CS1061 “FormClosedEventArgs”未包含“Cancel”的定义,并且找不到可接受第一个“FormClosedEventArgs”类型参数的扩展方法“Cancel”(是否缺少 using 指令或程序集引用?) WindowsFormsApplication4 E:\C#\NO.1\WindowsFormsApplication4\WindowsFormsApplication4\Form1.cs 24 活动

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

namespace WindowsFormsApplication4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_FormClosing(object sender,FormClosedEventArgs e)
        {
            DialogResult dr = MessageBox.Show("sdsds", "fer", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (dr ==DialogResult.Yes)
            {
                e.Cancel = false;
            }
            else
            {
                e.Cancel = true;
            }
        }
    }
}

和教材提供的代码比对,代码都一样的,但是为什么提示未包含Cancel的定义呢?

分享到:
精彩评论 1
小科_mrkj
学分:43 LV2
2016-06-03
沙发
读者朋友:
    您好,把.Cancel删除,然后点.,从出现的列表中选择取消属性,看看有没有。
首页上一页 1 下一页尾页 1 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照