locked
Event not firing RRS feed

  • Question

  • Hi there,

    Does anyone know why the "ColumnChanged" event isn't fired when "Merge()" is
    called below. "OnRowChanged()" is fired however: Thanks in advance.

    private static void Test()
    {
        DataSet ds1 = new DataSet();
        DataTable dt1 = ds1.Tables.Add("MyTable");
        DataColumn primaryKeyColumn = dt1.Columns.Add("Key", typeof(int));
        dt1.PrimaryKey = new DataColumn[] { primaryKeyColumn };
        dt1.Columns.Add("Name", typeof(string));
        DataRow dr1 = dt1.Rows.Add(1, "John");
        ds1.AcceptChanges();

        DataSet ds2 = ds1.Copy();
        ds2.Tables["MyTable"].Rows[0]["Name"] = "David";

        dt1.RowChanged += OnRowChanged;
        dt1.ColumnChanged += OnColumnChanged;
        ds1.Merge(ds2);
    }

    private static void OnRowChanged(object sender, DataRowChangeEventArgs e)
    {
    }

    private static void OnColumnChanged(object sender, DataColumnChangeEventArgs
    e)
    {
    }

    Tuesday, May 22, 2007 12:47 PM

Answers

  • It doesn't look like the event is wired up correctly.  It should look like this...

     

    dt1.RowChanged += new DataRowChangeEventHandler(OnRowChanged);

    dt1.ColumnChanged += new DataColumnChangeEventHandler(OnColumnChanged);

    Friday, May 25, 2007 5:28 PM

All replies

  • Ok, MSFT has now confirmed this is a bug and has submitted it for repair (after filing a report with them)
    Wednesday, May 23, 2007 12:47 PM
  • It doesn't look like the event is wired up correctly.  It should look like this...

     

    dt1.RowChanged += new DataRowChangeEventHandler(OnRowChanged);

    dt1.ColumnChanged += new DataColumnChangeEventHandler(OnColumnChanged);

    Friday, May 25, 2007 5:28 PM
  • My example relies on the new streamlined syntax available in .NET 2.0. In any case, MSFT has confirmed this is a bug as previously noted:

     

    http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=278081

    Saturday, May 26, 2007 2:46 AM
  • My apologies, I'd not seen that syntax before.  You learn something new every day. Smile

    Saturday, May 26, 2007 3:11 AM