Hi,
did you have an example how to create and destroy a multilevel menu to an existing subitem-menu entry.
I have one dxBarSubitem and depending on the contents of a config file i want to create a tow level menu. Every time when the config file is reloaded the menu should be recreated.
I can't figure it out so easy, so i hope you have an example :-)
Greetings and thanks
Jens
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Hi Jens,
Please review the following Knowledge Base article that may be helpful:
"How to perform full creation at runtime"
Article ID: A177 (https://www.devexpress.com/kb=A177)
Feel free to contact us if you need any further assistance in this regard.
Thanks,
Serge
P.S. When posting a report to the Support Center, please specify the exact version of our component you are working with. Sentences like "Latest" or "Updated today" are not informative (just because we release different updates). Thus, such reports require additional round-trips to ask you for more information about the version. Leaving the Version field empty is not good either. In such situations, we suppose that you are using the latest build … and this may be not true.
Hi Serge,
i have seen the kb entry, but my hope was that you have a sample which fits my needs a little bit more.
I've tried it, but i've got problems whit the dynamicly creation and destroying of the buttons and submenus.
But i will give it a new try . :-)
Greetings
Jens
P.S. Next time i will give the exact version number :-)
Sorry, Jens, I do not quite understand which peculiar approach you are using and why it precludes you from using the code from the article. The sample illustrates how to create different elements in code: menus, toolbars, items, item links and so on. This allows you to fully customize your menu system dynamically. If you need any further assistance on this subject, please clarify your concern in more details and we will try to find an acceptable solution for you.
Thanks,
Serge
Hi Serge,
as i have written, my main problem was lack of time, and so point that i'm not sure how to savely delete old items.
This is my current implementation:
procedure tOraToolMainForm.UpdateToolsMenu;
var i: integer;
Btn : TdxBarButton;
Itm : TdxBarItem;
act:TecMultiReplaceItemAction;
// mi: TMenuItem;
procedure ClearMenu (MenuItem : TdxBarSubItem);
var i : integer;
begin
for i := 0 to MenuItem.ItemLinks.Count - 1 do
begin
if Assigned(MenuItem.ItemLinks[i].Item.Action) then
begin
MenuItem.ItemLinks[i].Item.Action.Free;
MenuItem.ItemLinks[i].Item.Action := nil;
end;
if MenuItem.ItemLinks[i].Item is TdxBarSubItem then
ClearMenu(TdxBarSubItem(MenuItem.ItemLinks[i].Item));
end;
MenuItem.ItemLinks.Clear;
end;
function GetCategory(const Cat: string): TdxBarSubItem;
var i: integer;
begin
for i := 0 to dxBarMultiReplaceMenu.ItemLinks.Count - 1 do
if (dxBarMultiReplaceMenu.ItemLinks[i].Item is TdxBarSubItem) and
(dxBarMultiReplaceMenu.ItemLinks[i].Item.Caption = Cat) then
begin
Result := TdxBarSubItem(dxBarMultiReplaceMenu.ItemLinks[i].Item);
Exit;
end;
Result := TdxBarSubItem.Create(Self);
Result.Caption := Cat;
with dxBarMultiReplaceMenu.ItemLinks.Add do
Item:= Result;
end;
begin
ClearMenu(dxBarMultiReplaceMenu);
for i := 0 to GlobalOptionsDataModule.SyntMultiReplace.Items.Count - 1 do
if GlobalOptionsDataModule.SyntMultiReplace.Items[i].Category <> '' then
begin
Act:= TecMultiReplaceItemAction.Create(Self);
Act.ItemIndex := i;
Act.MultiReplace := GlobalOptionsDataModule.SyntMultiReplace;
Btn := TdxBarButton.Create(self);
Btn.Action := Act;
with GetCategory(GlobalOptionsDataModule.SyntMultiReplace.Items[i].Category).ItemLinks.Add do
item := Btn;
end;
dxBarMultiReplaceMenu.Enabled := dxBarMultiReplaceMenu.ItemLinks.Count > 0;
end;
dxBarMultiReplaceMenu is the menu where all entries should be generated.
One question is open: Is the way of deleting the old items correct?
Greetings and thanks
Jens
This code is basically correct, however, I should draw your attention to the following things:
You will find some articles which illustrates the use of this property in our Knowledge Base:
https://www.devexpress.com/Support/Center/SearchResults.aspx?searchtext=LockUpdate&pgid=48409584-e723-41af-b1d3-52dd97577823&pid=07aa3ad0-3f72-4cfb-8469-6e26d1185515&default=KB
Thanks,
Serge
Hi Serge,
thanks for the last infos. This were the infos i'm looking for.
Greetings
Jens
No worries, Jens. You are always welcome :)
Thanks,
Serge