# Sub Menu.Close problem

**URL:** <https://forum.xojo.com/t/sub-menu-close-problem/84595>\
**Category:** Windows\
**Created:** [March 17, 2025, 10:17am UTC](https://forum.xojo.com/t/sub-menu-close-problem/84595 "2025-03-17T10:17:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_ROBISSON](https://forum.xojo.com/user_avatar/forum.xojo.com/thomas_robisson/32/25592_2.png) [@Thomas\_ROBISSON](https://forum.xojo.com/u/Thomas_ROBISSON)\
**Post date:** [March 17, 2025, 10:17am UTC](https://forum.xojo.com/t/sub-menu-close-problem/84595/1 "2025-03-17T10:17:23Z")

</div>

I discovered a problem of one of my application under Windows. I don’t know if the problem is there for a long time or not as I don’t test (and use) my applications under Windows as much as under MacOS.  
Please donwnload the sample problem  
[SubMenu.xojo\_binary\_project.zip](https://forum.xojo.com/uploads/short-url/feC37Pg0OozMSfSZeRRkQhH9lvJ.zip) (7.2 KB)  
and run it. It simply creates submenu of menu File - Untitled . After the launch, there’s only one submenu “…”, click button “Make MenuA” and “Make MenuB” and “Make MenuC” some times in any order. → No problem.  
Check the box CheckBox1 “Use Close (checked) or RemoveMenuAt (unchecked)” and problems will happen. The submenu are not removed. This problem appears only under Windows, not under MacOS.  
Note: Label1 display the name of the submenu clicked, its index and the count of submenus.  
Is it a bug or is it the way Menu.Close is supposed to work?

No need to use the others CheckBox 2 and 3, I added them to understand the different ways to manage submenu as explained in the doc and in the Xojo example project “Open Recent Menu”.

---

<div class="post-metadata">

**Author:** ![Greg\_O](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o/32/22785_2.png) [@Greg\_O](https://forum.xojo.com/u/Greg_O)\
**Post date:** [March 17, 2025, 10:54am UTC](https://forum.xojo.com/t/sub-menu-close-problem/84595/2 "2025-03-17T10:54:53Z")

</div>

Have you tried just setting visible to false?

---

<div class="post-metadata">

**Author:** ![Thomas\_ROBISSON](https://forum.xojo.com/user_avatar/forum.xojo.com/thomas_robisson/32/25592_2.png) [@Thomas\_ROBISSON](https://forum.xojo.com/u/Thomas_ROBISSON)\
**Post date:** [March 17, 2025, 11:27am UTC](https://forum.xojo.com/t/sub-menu-close-problem/84595/3 "2025-03-17T11:27:52Z")

</div>

No, and I don’t think it will be usefull in my project. It is a memory game and the user can select a folder containing subfolders of CardsGame. Then he may select a folder with 8 cardsgame folder with their name, and then another folder containing 22 cardsgame with another name. And the way I do it (using **RemoveMenuAt** instead of **Close** works, but before submit a bug report I wanted to know if it is a bug. I think it is but I’m not sure.

---

<div class="post-metadata">

**Author:** ![Rick\_Araujo](https://forum.xojo.com/user_avatar/forum.xojo.com/rick_araujo/32/251_2.png) [@Rick\_Araujo](https://forum.xojo.com/u/Rick_Araujo)\
**Post date:** [March 17, 2025, 1:02pm UTC](https://forum.xojo.com/t/sub-menu-close-problem/84595/4 "2025-03-17T13:02:43Z")

</div>

Your code is confuse, uncommented, trying to pack several functionalities in one method alone like “closing or removing menus” in one function called “MakeSubMenu”.

That’s not a good design, hard to others to read and follow, and maybe works for the person who wrote it, but even that person can get confused with it in the future.

Try to separate your functionalities, as InsertGameIntoMenu(…) and RemoveGameFromMenu(…)  
And when the remove function does not work it will be easier to see where and why it fails, sometimes it is just a dev logic fail he will catch when designing more specifically the functionalities.

If you still have problems after a redesign, remove all garbage from the sample, and post just the parts involved to avoid noise about the problem, like removing everything and having just one button with a ShowProblem()

---

<div class="post-metadata">

**Author:** ![Thomas\_ROBISSON](https://forum.xojo.com/user_avatar/forum.xojo.com/thomas_robisson/32/25592_2.png) [@Thomas\_ROBISSON](https://forum.xojo.com/u/Thomas_ROBISSON)\
**Post date:** [March 20, 2025, 9:56am UTC](https://forum.xojo.com/t/sub-menu-close-problem/84595/5 "2025-03-20T09:56:52Z")

</div>

Thank you for yours answers. I simplify my example project and I created an issue [#78727](https://tracker.xojo.com/xojoinc/xojo/-/issues/78727) .  
The result should be the same under MacOS and Windows.

---

<div class="post-metadata">

**Author:** ![Rick\_Araujo](https://forum.xojo.com/user_avatar/forum.xojo.com/rick_araujo/32/251_2.png) [@Rick\_Araujo](https://forum.xojo.com/u/Rick_Araujo)\
**Post date:** [March 20, 2025, 5:09pm UTC](https://forum.xojo.com/t/sub-menu-close-problem/84595/6 "2025-03-20T17:09:31Z")

</div>

Here is my approach based on what I’ve saw:

[SubMenu\_redesigned.zip](https://forum.xojo.com/uploads/short-url/cGk0NhkI35qqpHRnLfUww1x6cdb.zip) (5.8 KB)

Even more simplified (just 2 menus) and better structured.

---

<div class="post-metadata">

**Author:** ![Rick\_Araujo](https://forum.xojo.com/user_avatar/forum.xojo.com/rick_araujo/32/251_2.png) [@Rick\_Araujo](https://forum.xojo.com/u/Rick_Araujo)\
**Post date:** [March 20, 2025, 6:19pm UTC](https://forum.xojo.com/t/sub-menu-close-problem/84595/7 "2025-03-20T18:19:28Z")

</div>

SubMenuItem.Close() is not updating LastRowIndex of the container when the item is removed using it.

---

<div class="post-metadata">

**Author:** ![Rick\_Araujo](https://forum.xojo.com/user_avatar/forum.xojo.com/rick_araujo/32/251_2.png) [@Rick\_Araujo](https://forum.xojo.com/u/Rick_Araujo)\
**Post date:** [March 20, 2025, 6:43pm UTC](https://forum.xojo.com/t/sub-menu-close-problem/84595/8 "2025-03-20T18:43:07Z")

</div>

Workaround fixing the problem:

Remove the MenuItem.Close()

Use RemoveMenuAt(index)

IF you did not close the sub MenuItem yet, it works, if you closed it, it will fail too later.

[SubMenu\_redesigned\_2.zip](https://forum.xojo.com/uploads/short-url/cu8vAJ85mu73nwFVuWe7UNzsbMR.zip) (5.8 KB)
