WobblyBob
WobblyBob

Reputation: 154

Delphi 11.3 DBLookupComboBox Scrolling Issues. Delphi 11.3

I have been having issues with the DBLookupComboBox not working correctly. Populating it and pointing it at the appropriate table works fine. Selecting an item and inserting into the appropriate table works fine also.

However scrolling down the DBLookupComboBox list of items does not work at all. The mouse wheel is ignored completely.

I found the following code in one of the other posts and it sort of makes scrolling work, but the scroll jumps 2 items at a time, skipping an item completely.

procedure TForm1.FormMouseWheelDown(Sender: TObject; Shift: TShiftState;
  MousePos: TPoint; var Handled: Boolean);

begin
if (DBLookupComboBox1.Focused() = true) then DBLookupComboBox1.Perform(WM_KEYDOWN, VK_DOWN, 0);
end;

procedure TForm1.FormMouseWheelUp(Sender: TObject; Shift: TShiftState;
  MousePos: TPoint; var Handled: Boolean);
begin

if (DBLookupComboBox1.Focused() = true) then DBLookupComboBox1.Perform(WM_KEYDOWN, VK_UP, 0);
end;

There are about 30 items in the combobox so clicking the up / down on the scroll bar is a bit of a none starter.

Any help Much appreciated, many thanks.

Upvotes: 0

Views: 483

Answers (1)

dnaka
dnaka

Reputation: 1

You should add "Handled := True".

    procedure TForm1.FormMouseWheelDown(Sender: TObject; Shift: TShiftState;
      MousePos: TPoint; var Handled: Boolean);
    begin
      if (DBLookupComboBox1.Focused() = true) then begin
        DBLookupComboBox1.Perform(WM_KEYDOWN, VK_DOWN, 0);
        Handled := True;
      end;
    end;

    procedure TForm1.FormMouseWheelUp(Sender: TObject; Shift: TShiftState;
      MousePos: TPoint; var Handled: Boolean);
    begin
      if (DBLookupComboBox1.Focused() = true) then begin
        DBLookupComboBox1.Perform(WM_KEYDOWN, VK_UP, 0);
        Handled := True;
      end;
    end;

Upvotes: 0

Related Questions