Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread TMenu itemindex
Sat, Feb 25 2017 5:48 AMPermanent Link

kamran

Hi

So I have a menu filled with options.
I want to use the selected menu item to do further processing down the line.

Just trying to work out how to get hold of the selected caption from a Tmenu

is the itemindex of menus available to check?

whats the format to get hold of this ?

My code:

function TMenuFrm.HeaderMenuItemClick(Sender: TObject): Boolean;
begin
 with  TIAMODataFrm.MenuHeader do
     begin
     Columns['menuheader_name'].SortDirection:=sdAscending;
     SortCaseInsensitive:=True;
     Sort;
     InitFind;

// get the menu caption of item selected here and use to find the record

    Columns['menuheader_name'].AsString:=Columns['menuheader_name'].AsString:=HeaderMenu.items[HeaderMenu.itemindex].Caption;

//

     if Find(False,True) then
     begin
        Result:=True;
     end
     else
        Result:=False;
     end;
end;



thanks

Kamran
Sat, Feb 25 2017 9:01 AMPermanent Link

Uli Becker

How about TMenuItem(Sender).Caption in the OnClick event.?
If you need an ID, you can use the MenuItem's tag and get the ID by TMenuItem(Sender).Tag.

Uli
Sat, Feb 25 2017 1:38 PMPermanent Link

kamran

Thanks Uli

I will have a go ...

cheers

kamran

Uli Becker wrote:

How about TMenuItem(Sender).Caption in the OnClick event.?
If you need an ID, you can use the MenuItem's tag and get the ID by TMenuItem(Sender).Tag.

Uli
Image