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
1 Answer
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.
5 Comments
Nalu
thanks david. i will try it. Can we pass integer value in OnSelect event of TComboBox?
David Heffernan
I don't understand that question
Nalu
Onselect event of TCombobox have parameters (Sender:TObject). can we pass any other parameter along with Sender?
David Heffernan
You can't change parameter lists for built in events. You could read information out of sender perhaps.