Problem with edit mode of custom cell type when switching from v7.35 to 12.45

Posted by: mayank1158336 on 11 December 2019, 8:37 am EST

    • Post Options:
    • Link

    Posted 11 December 2019, 8:37 am EST - Updated 30 September 2022, 1:40 pm EST

    I am getting a crash while trying to edit the cell, we are using a wrapper over EditBaseCellType and using an instance of Windows.forms inside it.

    The issue happens when we edit the cell for the first time and StopEditing event gets calls Dispose() for the base class, where the control gets disposed.

    Next time when we try to access control we get the crash, this issue was not happening in v7.35 and happens only after the upgrade.

    if I override the InitializeEditorControl and instantiate the form object there the issue gets resolved,

    is this the right way to do?

    I am providing the methods

    public override Control GetEditorControl(FarPoint.Win.Spread.Appearance appearance, float zoomFactor)

    { UserControl ResultNumeric accept = null;

    accept.LessThan = false;

    accept.GreaterThan = false;

    accept.NumericResult = 0;

    accept.NumericResultString = " ";

    accept.SetResultFormat(m_dataMapMin, m_dataMapMax, m_dataMapDec);

    accept.SciNotationItemName = this.SciNotationItemName;

    accept.SuppressGreaterLessThan = this.SuppressGreaterLessThan;

    accept.AssayName = this.AssayName;

    return accept;

    }

    // this implementation resolves the issue

    public override void InitializeEditorControl(Control control, FarPoint.Win.Spread.Appearance appearance, float zoomFactor)

    {

    accept = new ResultNumeric();

    base.InitializeEditorControl(control, appearance, zoomFactor);

    }

    public override Control GetEditorControl(FarPoint.Win.Spread.Appearance appearance, float zoomFactor)

    {

    base.GetEditorControl(appearance, zoomFactor);

    accept.LessThan = false;

    accept.GreaterThan = false;

    accept.NumericResult = 0;

    accept.NumericResultString = " ";

    accept.SetResultFormat(m_dataMapMin, m_dataMapMax, m_dataMapDec);

    accept.SciNotationItemName = this.SciNotationItemName;

    accept.SuppressGreaterLessThan = this.SuppressGreaterLessThan;

    accept.AssayName = this.AssayName;

    return accept;

    }

  • Posted 13 December 2019, 2:53 am EST

    Hi,

    Your first code seems to be incorrect:

    UserControl ResultNumeric accept = null;
    accept.LessThan = false;
    

    So, I’m not certain but it looks like earlier you were using a single UserControl instance as the editor. After your fix, you are creating a new instance on each edit, which is correct.

    If you still want to re-use a single instance, then you can implement ‘IReuseEditorControl2’ interface on your cell type.

    Regards,

    Jitender

  • Posted 16 December 2019, 1:36 am EST

    this UserControl ResultNumeric accept is declared as static in the class, I just demonstrated in the method to have clarity.

    Are there any other methods can we use to use a single instance?

    Also earlier we were not overriding InitializeEditorControl, I just implemented that approach to create a new instance, due to dispose()

  • Posted 16 December 2019, 1:47 am EST

    Have you tried implementing IReuseEditorControl2 on the cell type? This is the recommended method to tell Spread to not dispose the editor instance after editing is completed.

  • Posted 16 December 2019, 5:45 am EST

    Yeah, implementing IReuseEditorControl2 resolves the problem. Thanks a lot for your help.

Need extra support?

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

Learn More

Forum Channels