为什么我的表格闪烁 [英] Why is my form blinking

查看:179
本文介绍了为什么我的表格闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我的表格在眨眼.
当我按下表单内的按钮时,表单将闪烁并且不会消失,然后按下按钮,表单将消失.
这是表单代码.

Why is my form blinking.
when i press a button inside the form,the form will blink and not disappear, and then press the button the form will disappear .
this the form code.

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

namespace Company_Accounts
{
    public partial class MyMessageBox : Form
    {

        static MyMessageBox newMessageBox;
        static string Button_id;
        public static DataGridViewRow dr;
        public Timer msgTimer;
        int disposeFormTimer; 
        public MyMessageBox()
        {
            InitializeComponent();
        }

        private void MyMessageBox_Load(object sender, EventArgs e)
        {
            ControlBox = false;
            disposeFormTimer = 30;
            newMessageBox.lblTimer.Text = disposeFormTimer.ToString();
            msgTimer = new Timer();
            msgTimer.Interval = 1000;
            msgTimer.Enabled = true;
            msgTimer.Start();
            msgTimer.Tick += new System.EventHandler(this.timer1_Tick ); 
        }
        public static string ShowBox(string txtMessage, string txtTitle)
        {
            newMessageBox = new MyMessageBox();
            newMessageBox.label3.Text = txtTitle;
            newMessageBox.label1.Text = txtMessage;
            newMessageBox.ShowDialog();
            return Button_id;
        }

        private void btnlist_Click(object sender, EventArgs e)
        {
            newMessageBox.msgTimer.Stop();
            Button_id = "3";
            this.Hide();
            this.Close();
           
        }

        private void btnrenter_Click(object sender, EventArgs e)
        {
            newMessageBox.msgTimer.Stop();
            Button_id = "1";
            this.Close();
          
        }

        private void btnadd_Click(object sender, EventArgs e)
        {
            newMessageBox.msgTimer.Stop();
            
            Button_id = "2";
            this.Close();
           
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            disposeFormTimer--;

            if (disposeFormTimer >= 0)
            {
                newMessageBox.lblTimer.Text = disposeFormTimer.ToString();
            }
            else
            {
                newMessageBox.msgTimer.Stop();
                newMessageBox.msgTimer.Dispose();
                newMessageBox.Dispose();
            }
        }
    }
}




plz,plz,任何人都可以帮助我




plz,plz, Anyone Can Help Me

推荐答案

private void btnlist_Click(object sender, EventArgs e)
      {
          newMessageBox.msgTimer.Stop();
          Button_id = "3";
          this.Hide();
          this.Close();

      }




对于上层事件,仅执行此操作. Close()hide应该不存在..您还必须提到要单击的按钮事件,这样才能真正帮助您了解该事件代码中的问题




for upper event do only this. Close() hide should not be there..also you have to mention which button event you are clicking so it would really help to understand what is the problem in that event code


这篇关于为什么我的表格闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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