MaterialSkin icon indicating copy to clipboard operation
MaterialSkin copied to clipboard

Form Closing Problem

Open manusoft opened this issue 3 years ago • 3 comments

I have two forms in my project frmContactList and frmContact. When I start the program it will show frmContact then i will click Create button to show frmContact. The problem is when I close frmContact form, it will close all forms. How can I fix this.

manusoft avatar May 09 '21 18:05 manusoft

Change method "TerminateOnClose" in "MaterialForm.cs" (~ at Line 651]

Before:

    private void TerminateOnClose(object sender, FormClosedEventArgs e)
    {
        Application.Exit();
    }

After:

    private void TerminateOnClose(object sender, FormClosedEventArgs e)
    {
        if (Application.OpenForms.Count > 0  && this == Application.OpenForms[0])
            Application.Exit();
    }

This will fix this problem.

falcomus avatar Aug 16 '21 13:08 falcomus

or shorter:

//Close application only if only one form is open (the MainForm

if (Application.OpenForms.Count == 1) Application.Exit();

falcomus avatar Aug 16 '21 13:08 falcomus

Another native option is:

if (ActiveMdiChild != null) Application.Exit();

jmelendezdev avatar Jul 12 '22 15:07 jmelendezdev

Thank you all. @falcomus
@jmelendezdev

manusoft avatar Jan 10 '23 18:01 manusoft

where do I find that file? because when installing through nuget, it only finds *.dll files i use vb.net, not C

benjachiban avatar Jan 23 '24 21:01 benjachiban

Hello, you can download the source code here:https://github.com/IgnaceMaes/MaterialSkin Don't know if there are VisualBasic sources available, if you can't find it - maybe you can convert the C# files with a VB to C# converter.I did a conversion from VB to C#, it worked like a charm. Ithink it should work in both directions.

If you have the sources, embed the project in your solution and add a reference to this project in your main project.

falcomus avatar Jan 30 '24 17:01 falcomus

https://marketplace.visualstudio.com/items?itemName=SharpDevelopTeam.CodeConverter

falcomus avatar Jan 30 '24 17:01 falcomus