Removing Labels previously created at run time

  1. last week

    So I have created labels from controls in a timer. I would like to later, delete the labels once the data is refreshed

  2. Norman P

    Sep 11 Pre-Release Testers, Xojo Pro great-white-software.com/blog

    look up Close for a control
    http://docs.xojo.com/Control.Close_method

  3. Dave S

    Sep 11 San Diego, California USA

    or just hide them

    label1.visible=false

    that way you can bring them back if you needed to

  4. Michel B

    Sep 12 Pre-Release Testers, Xojo Pro RubberViews.com
    Edited last week

    @jim h So I have created labels from controls in a timer. I would like to later, delete the labels once the data is refreshed

    You need to keep a reference to each created label.

    Instead of DIMing the new label, use for instance an array of labels as a property of the window or a dictionary, so you do

    LabelsArray() as Label

    Is a property of the window.

    LabelsArray.append(New Label1)
    LabelsArray(LabelsArray.Ubound).Caption = "Clone"
    LabelsArray(LabelsArray.Ubound).Left = Me.Left + 10

    (Code adapted from the LR)

    You can then do something like:

    LabelsArray(2).close

or Sign Up to reply!