Reputation: 1117
I have created an packaged object (TMyComponent) of TLabel and TCombobox in delphi 7. I have created an dynamic array(MyArray) of TMyComponent. Now on Add button click I have increamented length of MyArray and create object of TLabel and TCombobox and displayed on screen. If I have added 5 components, How we can get current selected component of Myaaray means if i selected 3rd component from screen then how can i get value 3 in return? thanks for help
Upvotes: 0
Views: 621
Reputation: 612784
I think you are looking for a function like this:
function FindMyComponentIndex(
Selected: TMyComponent;
const Components: array of TMyComponent
): Integer;
begin
for Result := low(Components) to high(Components) do
if Components[Result]=Selected then
exit;
Result := -1;
end;
I trust it will be obvious how to call this function.
Upvotes: 3