Solved

Component linking

Posted on 2001-07-14
1
176 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now