Jump to content

Refreshing an UniTreeMenu


RaoulW

Recommended Posts

Hi,

Newbie user and looks great!

I'm tring to update a TUniTreeMenu inside the event handler of a menu item. When I do this, the entire menu is ducplicated. I have tried:

    UniTreeMenu1.BeginUpdate;
    UniTreeMenu1.SourceMenu := nil;

   MyMenuItems.Clear;

etc.

MyMenuItems is a sub menu. 

 

What am I doing wrong?

 

Link to comment
Share on other sites

7 hours ago, RaoulW said:

I'm tring to update a TUniTreeMenu inside the event handler of a menu item. When I do this, the entire menu is ducplicated. I have tried:

    UniTreeMenu1.BeginUpdate;
    UniTreeMenu1.SourceMenu := nil;

   MyMenuItems.Clear;

etc.

MyMenuItems is a sub menu. 

Hello,

Please provide more details.

Link to comment
Share on other sites

Hi, 

I believe there is some gap or at least handled different with the html menu compared to native delphi.

If you skip the following 4 lines (2 before your updates and 2 after your updates) the menu is updated correct. So changes are not updated correctly on the UniTreeMenu1 when using .BeginUpdate / .EndUpdate (So at least these lines mustn't be used for the menu to be updated correctly.



    UniTreeMenu1.BeginUpdate;
    UniTreeMenu1.SourceMenu := nil;

// All other code...

  UniTreeMenu1.EndUpdate;
  UniTreeMenu1.SourceMenu := UniMenuItems1;

 

Link to comment
Share on other sites

Hi,

You must delete each item:

 

    I := UniTreeMenu1.Items.Count-1;

    while(I > 0) do
      begin
        UniTreeMenu1.Items.Delete(UniTreeMenu1.Items.Item[I]);
        I := UniTreeMenu1.Items.Count-1;
        If(I = 0)then
          UniTreeMenu1.Items.Delete(UniTreeMenu1.Items.Item[0]);
      end;

Link to comment
Share on other sites

Hi,

 

 

Thanks for the help. Unfortunately it does not help. I have to re-create a submenu so I changed your example to:

 

    for i := SubMenu.Count-1 downto 0 do
    begin
      for j := SubMenu[i].Count-1 downto 0 do
         SubMenu[i].Delete(j);
      SubMenu.Delete(i);
    end;

 

But that results in the entire menu dissapearing. Using the BeginUpdate and/or SourceMenu := 0 has no effect, the menu stays blank.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...