D
dvestal
The included program produces this output to the debug stream:
Changed!
Changed!
Changed!
Why does the event fire three times? Can I configure it such that it
only fires when the Current item is actually different?
My source program follows:
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Diagnostics;
namespace WindowsApplication3
{
static class Program
{
[STAThread]
static void Main()
{
BindingSource src = new BindingSource();
BindingList<string> list = new BindingList<string>(
new string[]
{
"Odd"
}
);
src.CurrentChanged += new EventHandler(src_CurrentChanged);
src.DataSource = list;
}
static void src_CurrentChanged(object sender, EventArgs e)
{
Debug.WriteLine("Changed!");
}
}
}
Changed!
Changed!
Changed!
Why does the event fire three times? Can I configure it such that it
only fires when the Current item is actually different?
My source program follows:
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Diagnostics;
namespace WindowsApplication3
{
static class Program
{
[STAThread]
static void Main()
{
BindingSource src = new BindingSource();
BindingList<string> list = new BindingList<string>(
new string[]
{
"Odd"
}
);
src.CurrentChanged += new EventHandler(src_CurrentChanged);
src.DataSource = list;
}
static void src_CurrentChanged(object sender, EventArgs e)
{
Debug.WriteLine("Changed!");
}
}
}