Question
“How do I hide some or all of the menu items for the Data Tab?”
Solution
Check to see that the user has the data tab active in the TabChanged event and typecast the Designer.Menu.Items property as a Data menu object to access the menu items.
Download: HideDataMenuItems.zip
Sample Delphi code:
procedure TForm1.ppDesigner1TabChanged(Sender: TObject);
var
lSubMenu: TppTBCustomItem;
lDataFileMenu: TdaDataFileMenu;
begin
if (ppDesigner1.Notebook.ActivePageIndex = 0) then
begin
// this can be used to get at any menu times
lSubMenu := ppDesigner1.Menu.Items[0]; // get file menu
ShowMessage(lSubMenu.Items[0].Caption);
// For the Data | File menu we can typecast as TdaDataFileMenu
// The TdaDataFileMenu class has properties that correspond to the items,
// see RBuilder\Source\daDataManager for the class declaration
if (lSubMenu is TdaDataFileMenu) then
begin
lDataFileMenu := TdaDataFileMenu(lSubMenu);
lDataFileMenu.Export.Visible := False; // hide Export menu item
end;
end;
end;