Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何编写一个不允许它在表单上多次放置的简单组件? 比如说,我已经在表单上放置了我的 TMyComponent,如果我要放置另一个 TMyComponent,它会通知“组件已经存在!” 并将取消组件在表单上的放置。
组件构造函数接受一个Owner参数:通常是您的表单(或 DataModule)。只需浏览列表,Owner.Components看看是否还有您的列表。如果有,请引发异常。
Owner
Owner.Components
这将阻止您在设计时和运行时添加您的组件。