我无法关闭子表格

时间:2019-05-26 11:04:28

标签: c# winforms cefsharp

我用JavaScri打开子表单[t,做了一些工作,现在我想关闭子表单,但是我不能用“ X”关闭子表单-它再次打开。

HTML-仅按钮

<button class="btn btn-info" id="btn1" onclick="cefCustomObject.showForm2();">Show Form2</button>
<script>
    $("#btn1").on('click',function () {
        cefCustomObject.showForm2();
    }); 
</script>

C#-CefCustomObject类-以workingForm开始我的新应用

public class CefCustomObject {
    private static ChromiumWebBrowser _browser = null;
    private static Form1 _initializeMainForm = null;

    public CefCustomObject(ChromiumWebBrowser originalBrowser, Form1 mainForm) {
        _browser = originalBrowser;
        _initializeMainForm = mainForm;
    }
    //open Form2
    public void showForm2() {
        WorkingForm workingForm = new WorkingForm();
        WorkingData workingData = new WorkingData();
        WorkingPresenter workingPresenter = new WorkingPresenter(workingForm, workingData);
        workingForm.ShowDialog();
    }
}

C#-类Form1

public Form1() {
    InitializeComponent();
    InitializeChromium();
    _browser.RegisterAsyncJsObject("cefCustomObject", new CefCustomObject(_browser, this));
}

C#-类WorkingForm

private void WorkingForm_FormClosing(object sender, FormClosingEventArgs e) {
    if (e.CloseReason == CloseReason.UserClosing) {
        e.Cancel = true;
        Dispose(true);
    }
}

我在workForm上做了一些工作。我单击“ X”,并且workForm再次打开!为什么?我该怎么办?

0 个答案:

没有答案