Trouble with events

Posted by: r3dh2t on 8 September 2017, 1:57 pm EST

  • Posted 8 September 2017, 1:57 pm EST


     I am having a bit of an odd problem.  I am trying to disable an event for a period of code using the following statement:

                this.dsdm.Changed -= new FarPoint.Win.Spread.Model.SheetDataModelEventHandler(this.dataModel_Changed);

     This seems to work about 90% of the time, but occasionally this statement doesn't work. 

    I went through it with the debugger, and before this line executes the change event points to this:

    {Method = {Void dataModel_Changed(System.Object, FarPoint.Win.Spread.Model.SheetDataModelEventArgs)}}

    but oddly enough right after this line it says the exact same thing:

     {Method = {Void dataModel_Changed(System.Object, FarPoint.Win.Spread.Model.SheetDataModelEventArgs)}}

    It is almost as if the compiler is ignoring my code to disable the change event.   Can you think of any reasons this might be the case?  I am thoroughly confused.


    - brad


  • Replied 8 September 2017, 1:57 pm EST

    Hello Brad,

    I am not able to replicate the issue, below is the code  snippet that I used to replicate the issue,

    private void Form1_Load(object sender, EventArgs e)


    FarPoint.Win.Spread.Model.ISheetDataModel isdm;

    isdm = (FarPoint.Win.Spread.Model.ISheetDataModel)fpSpread1.ActiveSheet.Models.Data;

    isdm.Changed -= new FarPoint.Win.Spread.Model.SheetDataModelEventHandler(this.dataModel_Changed);

    isdm.ColumnCount = 5;

    isdm.RowCount = 5;

    isdm.SetValue(2, 2, "Model Changed");


    private void dataModel_Changed(object sender, FarPoint.Win.Spread.Model.SheetDataModelEventArgs e)


    textBox1.Text = "Model Changed";



    The dataModel_Changed Event doesnt after removing the Handler.Once the Handler is added the Event does fire again.I tested this code sevreral times.

    Let me know if I missed something.




  • Replied 8 September 2017, 1:57 pm EST

    Hi Deepak,

    I'm afraid I was doing something foolish in my code.  Got it fixed!   Thanks.

    - b


Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels