Solved

Component linking

Posted on 2001-07-14
1
184 Views
Last Modified: 2010-04-06
I have 2 components, one linked to the other via a property. Deleting the component which was selected by the other ends up with access violations. How can I capture this event and what should I do then?
Thanks,
Gurkan AKTAS
0
Comment
Question by:Gurkan
1 Comment
 
LVL 3

Accepted Solution

by:
nnbbb09 earned 50 total points
ID: 6282267

You need to override the notification method which is declared in TComponent as :

procedure Notification(AComponent: TComponent; Operation: TOperation); virtual;

All you need to do is check if AComponent is the same as the object that you are interested in and if the Operation = opRemove. If both these conditions are true then set your object property to nil.

This is what TDBEdit does when it's datasource is deleted

procedure TDBEdit.Notification(AComponent: TComponent;
  Operation: TOperation);
begin
  inherited Notification(AComponent, Operation);
  if (Operation = opRemove) and (FDataLink <> nil) and
    (AComponent = DataSource) then DataSource := nil;
end;

Hope this helps

Jo
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question