如何在关闭xcool窗口窗体时停止关闭整个应用程序 [英] How to stop closing whole application while closing xcool window form

查看:76
本文介绍了如何在关闭xcool窗口窗体时停止关闭整个应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像CMS这样的项目...我正在努力....我已经添加了一个主题xcool ....

这里有50个窗口窗口

但现在的问题是,当关闭一个Window窗体时,整个应用程序正在关闭..

什么问题....当我删除这个主题时它的工作正常。

i没有找到任何关闭主题方法..等请帮助我任何一个





这不是简单的窗口形式......我申请了一个主题.....我也尝试过多次Form.FormClosing活动(或类似活动)....



i am关闭单个窗口表单(主题应用)整个应用程序关闭...如果我从中删除主题,它工作正常...但是当一个应用主题然后它创建问题..



请帮助我,我在这里使用主题... https://www.codeproject.com/articles/33716/WebControls/?fid=1536616&df=90&mpp=25&排序=位置&安培;图=正常&安培; SPC =宽松&安培; FR = 71&安培;教授=真#usingcode




我的尝试:



i have a Project like CMS... am working on it.... i have add a theme xcool ....
there are 50 Window Form Here
but now problem is that while closing one Window form, the Whole application are closing..
whats Problem.... When i removing this theme its working good.
i don not find any closing Method of Theme..etc Please Help me any one


This is Not Simple Window Form ...... i apply on it a Theme .....i have also try Form.FormClosing event (or similar) many time ....

i am Closing a Single Window Form(Theme applied) the whole application closing...while if i removed theme from it, it work Good... but when a Apply theme then it Create problems..

Please Help me i am Using Themes from Here... https://www.codeproject.com/articles/33716/WebControls/?fid=1536616&df=90&mpp=25&sort=Position&view=Normal&spc=Relaxed&fr=71&prof=True#usingcode


What I have tried:

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;
using System.Data.Sql;
using System.Data.SqlClient;
using System.IO;
namespace CampusManagement
{
    public partial class YearMonthSet :XCoolForm.XCoolForm
    {
        public YearMonthSet()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
             try
                 {
                     // comboBox3.Items.Clear();//   MessageBox.Show("" + prft);
                     SqlConnection con = new SqlConnection("user id=;" +
                                      "password=;server=localhost\\SQLEXPRESS;" +
                                      "Trusted_Connection=yes;" +
                                      "database=CMS; " +
                                      "connection timeout=30");
                     con.Open();
                     ////////////////////YMCode///////////////
                     ///////////////////////////////////////////////////////for year month code ////////////////////////////////

                     SqlCommand cmd03 = con.CreateCommand();
                     cmd03.CommandText = "SELECT [YMCode]  FROM [CMS].[dbo].[YearMonth] where [YCode]=" + comboBox1.SelectedValue + " and [MCode]=" + comboBox5.SelectedValue + "";
                     SqlDataReader dr;
                     dr = cmd03.ExecuteReader();
                     dr.Read();
                     string ymcode = dr.GetValue(0).ToString();
                     Global.YMcode1 = ymcode.ToString();
                     Global.Yeaar1 = comboBox1.Text;
                     Global.Month1 = comboBox5.Text;
                     MessageBox.Show("Year Month Changed Successfully! ");
                     dr.Close();
                     this.Hide();
                 }
             catch (Exception ee)
             {
                 MessageBox.Show("Error! " + ee.ToString());

             }
             label4.Text =Global.Month1+ Global.Yeaar1.ToString();
           
        }
        private XmlThemeLoader xtl = new XmlThemeLoader();
        private void YearMonthSet_Load(object sender, EventArgs e)
        {
            
            this.TitleBar.TitleBarBackImage = CampusManagement.Properties.Resources.predator_256x256;
            this.MenuIcon = CampusManagement.Properties.Resources.alien_vs_predator_3_48x48.GetThumbnailImage(24, 24, null, IntPtr.Zero);
            xtl.ThemeForm = this;
            this.Border.BorderStyle = XCoolForm.X3DBorderPrimitive.XBorderStyle.Flat;
            this.TitleBar.TitleBarBackImage = CampusManagement.Properties.Resources.Mammooth_1;
            this.TitleBar.TitleBarCaption = "Campus Management System";
            xtl.ApplyTheme(Path.Combine(Environment.CurrentDirectory, @"..\..\Themes\BlueWinterTheme.xml"));
           
            label4.Text = Global.Month1 + Global.Yeaar1.ToString();
            // TODO: This line of code loads data into the 'cMSDataSetMonth.Month' table. You can move, or remove it, as needed.
            this.monthTableAdapter.Fill(this.cMSDataSetMonth.Month);
            // TODO: This line of code loads data into the 'cMSDataSetYear.Year' table. You can move, or remove it, as needed.
            this.yearTableAdapter.Fill(this.cMSDataSetYear.Year);

        }

推荐答案

当您关闭在中打开的第一个表单时主方法(在Program.cs中)通过 Application.Run 它存在Run方法并返回Main - 然后退出并终止应用程序,释放它使用的所有资源 - 这也意味着关闭它打开的所有窗口。你不能阻止这种情况,你也不应该这样做,因为如果你不这样做那么就没有办法关闭整个应用程序并清除内存。



我建议处理Form.FormClosing事件(或类似事件),它允许你闪现你确定要关闭这个应用程序吗?对话框,如果用户不想使用EventArgs的Cancel属性取消表单关闭,则不会退出应用程序。
When you close the first form that is opened in the Main method (in Program.cs) via Application.Run it exist the Run method and returns to Main - which then exits and that terminates the application, releasing all resources it used - which also means closing all windows it has open. You can't prevent that, and neither should you want to because if you don't do that then there is no way to shut down the whole app and clear it out of memory.

What I'd suggest to handling the Form.FormClosing event (or similar) which allows you to flash up a "Are you sure you want to close this app?" dialog and if the user doesn't want to using the Cancel property of the EventArgs to cancel the form closure an thuis not exit the app.


这篇关于如何在关闭xcool窗口窗体时停止关闭整个应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆