I'm trying to add some objects in a listbox (throw a binding list), but when i'm displaying the list, the static member of the class has always the same display, the last value. There is no problem in my list or class for the other properties.
In my form:
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
shape.gsPtAcc = ptdep;
if (shape is Segment)
{
seg = shape as Segment;
seg.gsScPtAcc = ptarr;
}
shape.incremNumber();
Console.WriteLine(shape.Number);//write the correct value
shapeList.Add(shape);
listBox1.DataSource = null;
listBox1.DataSource = shapeList;
}
}
In my mother class, shape:
namespace MyGraphicComponents
{
abstract class Shape: IComparable<Shape>, IDrawable, INotifyPropertyChanged, IIsPointIn
{
protected MyPoint ptAcc;
public MyPoint gsPtAcc
{
get { return ptAcc; }
set { ptAcc = value; }
}
protected static int compt = 0;
public int Number
{
get { return compt; }
set { compt = value; }
}
public int incremNumber ()
{
return ++compt;
}
}
}
So the result, when i'm adding shape will be:
In the console: 1 2 3 4 5
But in the listbox: 5 5 5 5 5