Reputation: 18720
I have a Delphi application A, which needs to select a certain item in a combo box of another Delphi application B.
A knows the text of the combo box item to select.
In order to select the combo box item, application A needs to know the index of the item in the combo box.
How can I figure out the index of a combo box item, when I only know its text?
Upvotes: 3
Views: 3235
Reputation: 109002
procedure TForm1.Button1Click(Sender: TObject);
var
SItem: string;
begin
SItem := 'Beta';
Caption := IntToStr(SendMessage(ComboBox1.Handle, CB_FINDSTRINGEXACT,
-1, LPARAM(PChar(SItem))));
end;
(uses CommCtrl
).
Upvotes: 9