how disable Delete button in TDiagramToolBar

Hi
I would like to prevent that the user can delete a block if it has still connections. I wrote a function IsConnected(...) to check it which is working correctly. I check it if a block is selected. How can I disable the Delete button in the ToolBar  to prevent deleting?
Or is it possible to prevent it in the event handler OnRemoveDControl ?

Thanks, Rolf

Hi Rolf,

You can add a crNoDelete restriction to the specified control:


DControl1.Restrictions := DControl1.Restrictions + [crNoDelete];

Hi Wagner

Thanks for the prompt answer! That prevents deleting
but it doesn't disable the delete button (resp. prevent to change it
from disable to enable) if I select the element. The user can still
click the delete button. Then I show a message box to explain why it's
not deleted. It may be better that way. Otherwise I need to show the
message on selection if the element is connected which would be more
often than in intension for deleting.