已有56人关注
删除按钮,弹出自定义的窗口,如何返回值,请老师指导一下,万分感谢。
发表在C#图书答疑 2010-09-05
是否精华
版块置顶:
//以下是删除按钮的代码

        private void _del_Click_1(object sender, EventArgs e)
        {
            frm_msg frm_ms = new frm_msg();
            cls_msg.msg = "确定删除 '" + Convert.ToString(dataGridView1[2, dataGridView1.CurrentCell.RowIndex].Value).Trim() + "' 吗!";            

            try
            {
                if (frm_ms.Show() == DialogResult.OK)  // 我用的是自己定义的消息窗体  书中原代码是if (MessageBox.Show("确定要删除该货物吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {

                    DataSet ds = new DataSet();
                    ds = dbOp.getDataSet("delete from tb_buy where _autoNum='" + Convert.ToString(dataGridView1[0, dataGridView1.CurrentCell.RowIndex].Value).Trim() + "'", "tb_buy");

                    UpdateDataGridView();
                    UpdateComobox();
                    UpdateComb_name();

                    cls_ClearControl clearC = new cls_ClearControl();
                    clearC.Clear_Control(groupBox1.Controls);   //清空相应文本框

                    _save.Visible = true;
                    _new.Visible = false;
                    _name.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
            }

        }








//以下是弹出提示的窗体

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

namespace IT部门管理系统
{
    public partial class frm_msg : Form
    {
        public frm_msg()
        {
            InitializeComponent();
        }

        private void frm_msg_Load(object sender, EventArgs e)
        {
            label1.Text = cls_msg.msg;            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            return ("ok");    //此处我该如何返回值,让前一删除窗体判断是否删除。请老师指导一下。
            this.Close();
        }

        private void btn_cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
分享到:
精彩评论 1
小科_mrkj
学分:43 LV2
2010-09-06
沙发
读者朋友:
    您好,用this.DialogResult=DialogResult.OK;设定返回值。
首页上一页 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经营性网站备案信息 营业执照