Вопрос

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?

Это было полезно?

Решение

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).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top