Results 1 to 3 of 3
  1. #1

    Properties of items in DotNETMenuStrip


    I have an application with a DotNETMenuStrip control. I am trying to check if items on the menus are enabled/disabled, but cannot find a way of doing this. I can obtain the name, and selected state of the menus items but nothing else.
    Does anyone know how I can obtain more information about the menu items?

    Here is how I get the name/selected state (in case this helps):

    Dim menuItems As TItems
    Set menuItems = DotNETMenuStrip("Menu").Items()

    Dim menuItem As Object
    For Each menuItem In menuItems

    MsgBox menuItem.Item(1)
    MsgBox menuItem.Item(2)


  2. #2
    Senior Member
    Join Date
    Jun 2002
    farmington hills, MI, US

    Re: Properties of items in DotNETMenuStrip

    I don't see any way of doing this through the TPOSI object DotNETMenuStrip, but you should be able to do something similar to the following. The following code assumes the menu is only two levels deep but could be adjusted for any depth.

    <font class="small">Code:</font><hr /><pre>
    Dim i, icount, i2, icount2 As Integer
    Dim o As Object

    'Get the count from the TPOSI object
    icount = DotNETMenuStrip("Name=menuStrip1").Count

    'Use a variable to reduce code redundancy and complexity
    Set o = DotNETMenuStrip("Name=menuStrip1").Object

    'Adjust the counters for 0 based arrays
    For i = 0 To icount - 1

    'Check our top level menu items
    MsgBox "Top Level item " &amp; i &amp; " enabled = " &amp; o.Items.Item(i).Enabled

    icount2 = o.Items.Item(i).DropDownItems.Count
    If icount &gt; 0 Then
    For i2 = 0 To icount2 - 1
    MsgBox "Second level item " &amp; i2 &amp; " enabled = " &amp; o.Items.Item(i).DropDownItems.Item(i2).Enabled
    End If
    </pre><hr />

    You could probably clean this up by adding a .NET reference to the library that contains the control. All I did was create a small sample app and then used a property check to see what was available under the .NET properties within the check. Hope it helps!

  3. #3

    Re: Properties of items in DotNETMenuStrip

    Many thanks chiefwiggum, that was exactly what I needed.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 07:45 PM.

Copyright BetaSoft Inc.