0

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 1

3

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.

Sign up to request clarification or add additional context in comments.

5 Comments

thanks david. i will try it. Can we pass integer value in OnSelect event of TComboBox?
I don't understand that question
Onselect event of TCombobox have parameters (Sender:TObject). can we pass any other parameter along with Sender?
You can't change parameter lists for built in events. You could read information out of sender perhaps.
@naren you should post another question, however you could do a cast on the sender and use Tag property to store an integer value, i.e. TComboBox(Sender).Tag

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.