2

I'm trying to clear an error Provider whenever a public static int entry variable is put to 0 ( this variable is static because I'm changing it's value from another form like this :

private void Profile_FormClosing(object sender, FormClosingEventArgs e)
    {
        this.Hide();
        Form1.entry = 0;

    }

)

So in my Main Form I setting that entry variable to 1 when I press a button like this:

private void button21_Click(object sender, EventArgs e)
    {
        if((TransferHair!=String.Empty)&& (TransferName != String.Empty))
        {
            if (entry == 0)
            {
                Profile pro = new Profile();
                pro.Show();
                entry = 1;
                errorProvider1.Clear();
            }
            else
            {
                //MessageBox.Show("You can't open more than 1 profile box!");
                errorProvider1.SetError(button21, "Close the previous profile before opening another!");


            }
        }
    }

But I do want to Clear that error immediately when the Profile form is closed and I am doing this:

private void entry_ValueChanged(object sender,EventArgs e)
        {
            if (entry == 0)
            {
                errorProvider1.Clear();
            }
        }

And it doesn't work!

I did this too:

public int TheEntry
    {
        get { return entry; }
        set
        {
            if(entry == 0)
            {
               // entry = 0;
                errorProvider1.Clear();
            }
        }
    }

Still not working!

I need a solution please!

Klas Lindbäck
  • 33,105
  • 5
  • 57
  • 82
  • Sorry dude, my fault, it's C# – Forgacs Norbert Feb 19 '16 at 11:07
  • 1
    [`INotifyPropertyChanged`](https://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(v=vs.110).aspx) interface is something I would look into. Good [example here](http://stackoverflow.com/questions/2246777/raise-an-event-whenever-a-propertys-value-changed) although it's covered on the msdn in pretty much the same fashion – Gabe Feb 19 '16 at 11:13

0 Answers0