Memo Properties become nothing

  • I am running into errors where Memo properties have become nothing....ie "An unhandled exception of type 'System.NullReferenceException' occurred..."

    For example:

    Code
    Me.editor.CurrMemo.LabelDef.Active = False

    fails occasionally because LabelDef is nothing or in this example

    Code
    Me.editor.CurrMemo.Clear(False, False)
    Me.editor.CurrMemo.CurrAttr.Clear()

    the second statement occasionally fails because CurrAttr is nothing.

    I would expect that a property should always be defined - ie never be "nothing", yes?

    I tried this with both version is 1.2.9.0 and 1.2.9.2, and got the same results.

    • Offizieller Beitrag

    Hi,

    >>I would expect that a property should always be defined - ie never be "nothing", yes? <<

    That is a management object, not a property. It can become "nothing" if the internal editor is not available. Other, similar properties can be "nothing", too, for example "Report" or "PDFCreator".

    I your case I do not belive this is the case. I rather think that the interface has somehow been freed - maybe because of a special constellation in your code. I don't know a single other coincidence where this happens. If you see the event log inside the IDE - does it give any information, such as internall messages or so? If you see this in a .NET exe which does not require special data to run - please send it to me and I can trace the problem.

    Julian

  • A little further investigation, and I have an example that can cause the problem (on occassion):

    Code
    Me.editor.CurrMemo.LabelDef.Active = False
    Me.editor.CurrMemo.RTFDataDelete("Labels")
    Me.editor.CurrMemo.LabelDef.Active = False


    I included the first line in the example to verify that LabelDef was not 'nothing'. The example can fail in the third line. The third line can fail because the LabelDef has become 'nothing' - a null reference.

    The manual mentions that the program should insure that another element is selected before deleting an element. Would this cause this problem?

    • Offizieller Beitrag

    Hi,

    >>The manual mentions that the program should insure that another element is selected before deleting an element. Would this cause this problem?<<

    This can cause any kind of problem. It is essential to select a different RTFData before you delete the one which is the current.

    'LabelDef' is strored in the RTFData, not the memo. So there is no need to 'Active' to false.

    It is possible to have multiple RTFData elements and each one has its own "LabeDef".

    Does this work for you?

    Me.editor.CurrMemo.RTFDataSelect("@@FIRST@@")
    Me.editor.CurrMemo.RTFDataDelete("Labels")

  • Selecting the @@FIRST@@ element, THEN deleting the "Labels" element works perfectly and resolves the problem.

    Since I was actually trying to completely reset the "Labels" element, I delete it, and then immediately add back and element with the same name...works like a charm...

    Thanks yet again for your advice and great support.