ItemChanged Event in C#

  • Thread starter Thread starter James Stewart
  • Start date Start date
J

James Stewart

Hi,
I am having problems getting the ItemChanged event to work (it is just not
firing). I followed the steps from KB 312045 INFO: Firing the Windows Forms
CurrencyManager Events in Visual C# .NET, but again, the ItemChanged event
is not firing in that example either.

I can get all the other events related to the currency manager to fire...

I would really like to understand what is going on.

Using Framework 1.1 with a local SQL Server Northwind database (for the KB
article).

Thanks,
James
 
Hi,
I am not too sure how to provide more info other than to submit the code
from the KB article... In summary, the code goes like this:
private void Form1_Load(object sender, System.EventArgs e)
{
....
// Bind the TextBox controls to the fields of the Employees table.
textBox1.DataBindings.Add("Text", ds.Tables["Employees"], "EmployeeID");
textBox2.DataBindings.Add("Text", ds.Tables["Employees"], "FirstName");
textBox3.DataBindings.Add("Text", ds.Tables["Employees"], "LastName");

// Specify the CurrencyManager for the Employees table.
myCurrencyManager =
(CurrencyManager)this.BindingContext[ds.Tables["Employees"]];

// Specify the event handlers for the CurrencyManager.
myCurrencyManager.CurrentChanged += new EventHandler(Current_Changed);
myCurrencyManager.ItemChanged += new
ItemChangedEventHandler(CurrencyManager_ItemChanged);
myCurrencyManager.PositionChanged += new EventHandler(Position_Changed);
}

Then I have the following code for the events:

private void Current_Changed(object sender, EventArgs e)
{
MessageBox.Show("Current_Changed");
}

private void CurrencyManager_ItemChanged(object sender,
System.Windows.Forms.ItemChangedEventArgs e)
{
MessageBox.Show("Item_Changed");
}

private void Position_Changed(object sender, EventArgs e)
{
MessageBox.Show("Position_Changed");
}

And the problem is that the ItemChanged event never executes. This code is
as is cut and paste from the Microsoft article. The two other events,
CurrentChanged and PositionChanged, work as described in the article, but
not the ItemChanged. I would like to know why because I can see that being a
useful event to capture.

Thanks,
James
 
Back
Top