6

I'm writing a custom component editor, essentially similar to TActionList editor in that it allows creation of sub components. Editor has buttons to add/delete components.

Now, I'd like to find out if selected component is inherited, so that I can disable the delete button. I haven't found any such member in IDesigner or related interfaces.

If I just go ahead and delete by Designer.DeleteSelection(True); then I get an exception:

Selection contains a component, xxx, introduced in an ancestor and cannot be deleted.

Which is not too bad, but I'd prefer to disable the delete button in the first place.

  • You can access the list of your items when you're selecting them in your list view (?) and ask for each item if `InheritsFrom` a certain class. – TLama Mar 04 '13 at 20:03
  • 1
    @TLama No, that's not it. Daniel talking about visual inheritance, as indicated by the inherited keyword in the .dfm files. – David Heffernan Mar 04 '13 at 20:27
  • I'd be surprised if this was possible. Try doing what you describe with a stock `TActionList`. The error message is: `Cannot rename component Action1, component was introduced in an ancestor form. `. But then click on the action and it disappears anyway and there's another error message: *Argument out of range*. So, the IDE can't get it right! – David Heffernan Mar 04 '13 at 20:31

1 Answers1

9

Ok, so apparently there is a way, by checking the TComponent.ComponentState for csAncestor, so:

csAncestor in ComponentState

And it's documented:

csAncestor - The component was introduced in an ancestor form. Only set if csDesigning is also set.