Click here to Skip to main content
15,919,358 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

C#
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, Anyone Can Help Me
Posted
Updated 21-Nov-12 1:08am
v2

1 solution

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

      }



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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900