# Enable MenuItem

**URL:** <https://forum.xojo.com/t/enable-menuitem/18495>\
**Category:** General\
**Created:** [August 10, 2014, 4:45pm UTC](https://forum.xojo.com/t/enable-menuitem/18495 "2014-08-10T16:45:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_T](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@Martin\_T](https://forum.xojo.com/u/Martin_T)\
**Post date:** [August 10, 2014, 4:45pm UTC](https://forum.xojo.com/t/enable-menuitem/18495/1 "2014-08-10T16:45:14Z")

</div>

Hi Everyone,

I’m a bit confused about the following fact:  
I have a MainMenubar with an Menuitem e.g. “Details” and named it to “mDetails”. I set AutoEnable to False.

If a row in a Listbox is selected, mDetail should set to Enabled = True, else False.  
[h]My Code[/h]

`Sub Change()
If Me.ListIndex > -1 Then
  mDetails.Enabled = True
Else
  mDetails.Enabled = False
End If
End Sub`

I work with Xojo Version 2014.2 and compile a Cocoa Application!

How to get it working?

Best regards!

---

<div class="post-metadata">

**Author:** ![Roger\_Clary](https://forum.xojo.com/letter_avatar_proxy/v4/letter/r/eada6e/32.png) [@Roger\_Clary](https://forum.xojo.com/u/Roger_Clary)\
**Post date:** [August 10, 2014, 4:47pm UTC](https://forum.xojo.com/t/enable-menuitem/18495/2 "2014-08-10T16:47:44Z")

</div>

You will need to enable and disable your menu item in the enableMenuitems event of the screen

---

<div class="post-metadata">

**Author:** ![Martin\_T](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@Martin\_T](https://forum.xojo.com/u/Martin_T)\
**Post date:** [August 10, 2014, 5:00pm UTC](https://forum.xojo.com/t/enable-menuitem/18495/3 "2014-08-10T17:00:29Z")

</div>

> [@119166:@Roger Clary](#):
>
> You will need to enable and disable your menu item in the enableMenuitems event of the screen

Hi Roger,  
thats laborious, but it works fine. I created a BooleanVariable, called EnableDetails!

`Sub Change()
If Me.ListIndex > -1 Then
  EnableDetails = True
Else
  EnableDetails = False
End If
End Sub`

Thank You!

---

<div class="post-metadata">

**Author:** ![Roger\_Clary](https://forum.xojo.com/letter_avatar_proxy/v4/letter/r/eada6e/32.png) [@Roger\_Clary](https://forum.xojo.com/u/Roger_Clary)\
**Post date:** [August 10, 2014, 9:09pm UTC](https://forum.xojo.com/t/enable-menuitem/18495/4 "2014-08-10T21:09:44Z")

</div>

> [@](#):
>
> thats laborious

Really? Seems so simple to me. Glad you got it working.

---

<div class="post-metadata">

**Author:** ![Eli\_Ott](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/5f8ce5/32.png) [@Eli\_Ott](https://forum.xojo.com/u/Eli_Ott)\
**Post date:** [August 10, 2014, 9:24pm UTC](https://forum.xojo.com/t/enable-menuitem/18495/5 "2014-08-10T21:24:50Z")

</div>

Just put this code in the EnableMenuItems event of the window:

```auto
mDetails.Enabled = ( Listbox1.ListIndex > -1 )
```

Replace Listbox1 with the name you gave your listbox in the window editor.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 5:22pm UTC](https://forum.xojo.com/t/enable-menuitem/18495/6 "2020-10-29T17:22:05Z")

</div>


