关闭C#表单但不关闭调用应用程序?

问题描述 投票:0回答:1

我有一个从我们的ERP调用的项目。 ERP调用C#项目中公开的功能,并且信息来回传递。这很好用,但是“取消”按钮有问题。当单击取消按钮时,我希望它关闭C#表单而不返回任何内容。...几乎只是终止C#中的任何操作并切断与ERP的连接。我尝试了许多形式的环境和应用程序命令,但它们也关闭了ERP和C#表单。是否有关于最佳方法的建议?我可以将对话框从按钮发送回ERP,只是不让ERP做任何具有真正价值的事情,但是我想知道是否没有更有效的方法来实现这一目标。预先感谢。

编辑:这是包含按钮的表单上的当前代码。取消按钮现在也已经设置为DialogResult =取消...

问题是,当实例化此表单时,将从ERP调用某些功能。使用this.close()会关闭表单,但它也会将值返回给ERP,我不希望这样做。

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 NavAutomation
{
    public partial class NAVForm : Form
    {
        public NAVForm(string frmName, int maxLen)
        {
            InitializeComponent();
        }

        private void NAVForm_Load(object sender, EventArgs e)
        {
        }

        public string RetVal1 { get; set; }
        public string txtB1 { get; set; }
        public int txtB1Len { get; set; }
        private void button2_Click(object sender, EventArgs e)
        {
            this.RetVal1 = textBox1.Text;

            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
            Application.Exit();
        }
    }
}
c# exit dynamics-nav formclosing
1个回答
0
投票

我最终要做的是,将默认布尔值设置为true,然后在取消按钮/关闭按钮上传递false,然后直接退出我们ERP中的调用代码,这就像在做梦一样。感谢您的评论。

© www.soinside.com 2019 - 2024. All rights reserved.