Forum Discussion
Bharadwaj
9 years agoContributor
function SelectItemFromListBox(listControl:OleVariant, listValue:string): boolean;
var
i, itemIndex: integer;
begin
result := false;
itemIndex := -1;
for i := 0 to listControl.wItemCount - 1 do
begin
if listControl.wItem[i] = Value then
begin
itemIndex := i;
break;
end;
end;
if itemIndex < 0 then
begin
Log.Error('Item value ''' + VarToStr(listValue) + ''' not found in list control ' + VarToStr(listControl.FullName), nil, nil, nil, listControl.Picture);
exit;
end;
listControl.Keys('[Home]');
for i := 0 to itemIndex - 1 do
listControl.Keys('[Down]');
result := true;
end;