Difference between revisions of "RibbonX Collections"

From Ribbon Commander Documentation
Jump to: navigation, search
(VBA)
(VBA)
Line 76: Line 76:
 
     ' Remove
 
     ' Remove
 
     myGroup.Buttons.Remove myButton4
 
     myGroup.Buttons.Remove myButton4
 +
   
 +
    ' Print number of buttons in the group (prints 0)
 +
    Debug.Print myGroup.Buttons.Count
 
      
 
      
 
End Sub
 
End Sub

Revision as of 17:01, 14 March 2013

This section is under construction. Please do not rely on any information it contains.


Description

The section describes the generic interface of Dynamic RibbonX collection and the operations that can be performed on them.


Properties

Property Name
Description
count Read-only property; returns the count of items in a collection
isEmpty Read-only property; returns true if the control is empty
isLive Read-only property; returns true if the control is live
item (VBA/VB.NET-specific) Returns a reference to a collection member by index or id
parent The control's parent object

Methods

Method Name
Description
add Adds an item to the collection
getItemIfExists Returns a reference to a collection member by index or id. Does not throw if the index or id is out of bounds.
remove Removes an item from the collection (by index or item reference)
removeAll Removes all items from the collection
operator[] (C#-specific) Returns a reference to a collection member by index or id
operator() (VBA/VB.NET-specific) Returns are reference to a collection member by index or id

Remarks

Examples

VBA

  1. Public Sub ColectionsVBASample()
  2.  
  3.     ' Create a new group and play with its buttons collection
  4.     Dim myGroup As rxGroup
  5.     Set myGroup = New rxGroup
  6.  
  7.     ' Print number of buttons in the group (prints 0)
  8.     Debug.Print myGroup.Buttons.Count
  9.  
  10.     ' Create a new button and give it an id
  11.     Dim myButton As rxButton
  12.     Set myButton = New rxButton
  13.     myButton.ID = "my_button"
  14.  
  15.     ' Add the button to the group's buttons collection
  16.     myGroup.Buttons.Add myButton
  17.  
  18.     ' Print number of buttons in the group (prints 1)
  19.     Debug.Print myGroup.Buttons.Count
  20.  
  21.     ' Access an item by index
  22.     Dim myButton2 As rxButton
  23.     Set myButton2 = myGroup.Buttons.Item(1)
  24.     ' Or alternatively
  25.     Set myButton2 = myGroup.Buttons(1)
  26.  
  27.     ' Access an item by id
  28.     Dim myButton3 As rxButton
  29.     Set myButton3 = myGroup.Buttons.Item("my_button")
  30.     ' Or alternatively
  31.     Set myButton3 = myGroup.Buttons("my_button")
  32.  
  33.     ' Remove an item by index
  34.     myGroup.Buttons.Remove 1
  35.  
  36.     ' Print number of buttons in the group (prints 0)
  37.     Debug.Print myGroup.Buttons.Count
  38.  
  39.     ' Add the item back and remove it by object reference
  40.     myGroup.Buttons.Add myButton
  41.     ' Get another ref to the button
  42.     Dim myButton4 As rxButton
  43.     Set myButton4 = myGroup.Buttons("my_button")
  44.     ' Remove
  45.     myGroup.Buttons.Remove myButton4
  46.  
  47.     ' Print number of buttons in the group (prints 0)
  48.     Debug.Print myGroup.Buttons.Count
  49.  
  50. End Sub

C#

  1.  

VB.NET

  1.  

C++

  1.