How to free control inside its event handler?

前端 未结 2 451
隐瞒了意图╮
隐瞒了意图╮ 2020-11-30 09:23

Does anybody know the trick, how to free control inside its event handler ? According delphi help it is not possible...

I want to free dynamicaly created TEdit, when

2条回答
  •  暖寄归人
    2020-11-30 09:57

    Before implementing this I would stop and ask "Is this really the best approach?"

    Do you really want an edit control class that always destroys itself when key input results in the Text property becoming an empty string?

    Is it not more likely to be the case that you have a specific form/dialog where this behaviour is required? In which case, there is no problem... you can free the edit control in the KeyUp event handled by the form without incurring an Access Violation.

提交回复
热议问题