Holger's Thoughts on Delphi

Monday, December 05, 2005

ECO III: CurrencyManagerHandle



There is a nice difference between ECO II and ECO III that is not visible, but very helpful when developing ECO Applications.

Let's say you have a CurrencyManagerHandle called "cmTeam" then you get the "selected" element in a grid, which is of the class type "Team" (if a DataGrid is the BindingContext) using:

aTeam := Team( cmTeam.Element.AsObject );

Problem: What happens if nothing is selected?
Solution: check if cmTeam.Element.AsObject is not equal to nil!

Be careful as it was more complicated in ECO II, this will only suffice in ECO III!

So to get an object of class "Team" of a list of teams in a grid you will have to use:

if ( Assigned( cmTeam.Element.AsObject ) ) then
begin
myTeam := Team( cmTeam.Element.AsObject );
....
end
else
// throw exception....
;



For the record: In ECO II you have to check for cmTeam.Element not equal to "nil" first.

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home