Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 4 of 4 total |
Iterating through MenuBar items |
Sun, May 30 2021 9:55 AM | Permanent Link |
StewCam | I have a form with a MenuBar. Currently I set the font of the active MenuBar item as bold on address anchor change using a block of type:
MenuBarItem1.Font.Style.Bold := True; MenuBarItem2.Font.Style.Bold := False: MenuBarItem3.Font.Style.Bold := False; This works but gets cumbersome as the number of MenuBar items increases. In order to reduce the number of repetitive false statements, I would like to iterate through the MenuBar items using a block of type: for i := 0 to MenuBar.ItemCount - 1 do begin MenuBar.Items[i].Font.Style.Bold := False; end; However,this syntax does not enable access to the font property, so I am looking for an alternative approach. |
Sun, May 30 2021 8:06 PM | Permanent Link |
Alan Questell Richmond Community College | Create a procedure ChangeFont in the form declaration
procedure ChangeFont(Sender: TComponent); Procedure as follows: procedure TForm1.ChangeFont(Sender: TComponent); begin if Sender is TMenuBarItem then TMenuBarItem(Sender).Font.Style.Bold := true; end; Pass the items to that procedure: begin for i := 0 to MenuBar1.ItemCount-1 do ChangeFont(MenuBar1.Items[i]); end; procedure TForm1.ChangeFont(Sender: TComponent); begin if Sender is TMenuBarItem then TMenuBarItem(Sender).Font.Style.Bold := true; end; StewCam wrote: I have a form with a MenuBar. Currently I set the font of the active MenuBar item as bold on address anchor change using a block of type: MenuBarItem1.Font.Style.Bold := True; MenuBarItem2.Font.Style.Bold := False: MenuBarItem3.Font.Style.Bold := False; This works but gets cumbersome as the number of MenuBar items increases. In order to reduce the number of repetitive false statements, I would like to iterate through the MenuBar items using a block of type: for i := 0 to MenuBar.ItemCount - 1 do begin MenuBar.Items[i].Font.Style.Bold := False; end; However,this syntax does not enable access to the font property, so I am looking for an alternative approach. |
Sun, May 30 2021 8:19 PM | Permanent Link |
Alan Questell Richmond Community College | Sorry, part of that got copied twice.
Alan Questell wrote: Create a procedure ChangeFont in the form declaration procedure ChangeFont(Sender: TComponent); Procedure as follows: procedure TForm1.ChangeFont(Sender: TComponent); begin if Sender is TMenuBarItem then TMenuBarItem(Sender).Font.Style.Bold := true; end; Pass the items to that procedure: begin for i := 0 to MenuBar1.ItemCount-1 do ChangeFont(MenuBar1.Items[i]); end; |
Mon, May 31 2021 6:43 AM | Permanent Link |
StewCam | Thanks very much for your advice, which resolved my problem.
Alan Questell wrote: Create a procedure ChangeFont in the form declaration procedure ChangeFont(Sender: TComponent); Procedure as follows: procedure TForm1.ChangeFont(Sender: TComponent); begin if Sender is TMenuBarItem then TMenuBarItem(Sender).Font.Style.Bold := true; end; Pass the items to that procedure: begin for i := 0 to MenuBar1.ItemCount-1 do ChangeFont(MenuBar1.Items[i]); end; |
This web page was last updated on Sunday, December 1, 2024 at 03:59 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |