How to trigger a click action on a TMenuItem in code? lazarus / 31-LCL ---------------------------------------------------------------------- ToolGIS · 2023-04-25 13:03 I have a custom event on a top menu item. The event is being handled fine. I'm trying to "Click" an item in another TListBox. Here's my code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TFormMain.MenuItemToolsClick(Sender: TObject);var  Tss : TStrings;  S: String;  I: Integer;begin  if Sender is TMenuItem then begin    I := 0;    Tss := FormMain.ListBoxToolboxes.Items;    for S in Tss do begin      if S = TMenuItem(Sender).Caption then begin        // This selects the item but I want to "Click" it.        FormMain.ListBoxToolboxes.Selected[I] := True;        Break      end;      I := I + 1;     end;  end;end; ---------------------------------------------------------------------- KodeZwerg · 2023-04-25 13:10 And does your ListBox having some OnClick Handler? If yes, just call it before the "break" like "ListBox1Click(Sender);" ---------------------------------------------------------------------- Zvoni · 2023-04-25 13:26 I'm trying to understand what OP tries to achieve. He has a MenuItem, and if he clicks there, code above is executed (as minimalist it is, nevermind some unneccessary code) He has a ListBox, and when the Caption of the MenuItem is found there, some specific code is to be executed? What code is executed, when user really clicks on a ListBox-Item? ---------------------------------------------------------------------- jamie · 2023-04-25 21:12 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i FormMain.ListBoxToolboxes.ItemIndex := I;FormMain.ListBoxToolboxes..OnClick(sender);  Add that after the selection ?