Difference between revisions of "RibbonX Collections"

From Ribbon Commander Documentation
Jump to: navigation, search
(Methods)
(VBA)
Line 31: Line 31:
 
=== VBA ===
 
=== VBA ===
 
<syntaxhighlight lang="vb" line>
 
<syntaxhighlight lang="vb" line>
 +
Public Sub ColectionsVBASample()
 +
   
 +
    ' Create a new group and play with its buttons collection
 +
    Dim myGroup As rxGroup
 +
    Set myGroup = New rxGroup
 +
   
 +
    ' Print number of buttons in the group (prints 0)
 +
    Debug.Print myGroup.Buttons.Count
 +
   
 +
    ' Create a new button and give it an id
 +
    Dim myButton As rxButton
 +
    Set myButton = New rxButton
 +
    myButton.ID = "my_button"
 +
   
 +
   
 +
    ' Add the button to the group's buttons collection
 +
    myGroup.Buttons.Add myButton
 +
   
 +
    ' Print number of buttons in the group (prints 1)
 +
    Debug.Print myGroup.Buttons.Count
 +
       
 +
    ' Access an item by index
 +
    Dim myButton2 As rxButton
 +
    Set myButton2 = myGroup.Buttons.Item(1)
 +
    ' Or alternatively
 +
    Set myButton2 = myGroup.Buttons(1)
 +
   
 +
    ' Access an item by id
 +
    Dim myButton3 As rxButton
 +
    Set myButton3 = myGroup.Buttons.Item("my_button")
 +
    ' Or alternatively
 +
    Set myButton3 = myGroup.Buttons("my_button")
 +
   
 +
    ' Remove an item by index
 +
    myGroup.Buttons.Remove 1
 +
   
 +
    ' Add the item back and remove it by object reference
 +
    myGroup.Buttons.Add myButton
 +
    ' Get another ref to the button
 +
    Dim myButton4 As rxButton
 +
    Set myButton4 = myGroup.Buttons("my_button")
 +
    ' Remove
 +
    myGroup.Buttons.Remove myButton4
 +
   
 +
End Sub
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Revision as of 15:59, 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.  
  16.     ' Add the button to the group's buttons collection
  17.     myGroup.Buttons.Add myButton
  18.  
  19.     ' Print number of buttons in the group (prints 1)
  20.     Debug.Print myGroup.Buttons.Count
  21.  
  22.     ' Access an item by index
  23.     Dim myButton2 As rxButton
  24.     Set myButton2 = myGroup.Buttons.Item(1)
  25.     ' Or alternatively
  26.     Set myButton2 = myGroup.Buttons(1)
  27.  
  28.     ' Access an item by id
  29.     Dim myButton3 As rxButton
  30.     Set myButton3 = myGroup.Buttons.Item("my_button")
  31.     ' Or alternatively
  32.     Set myButton3 = myGroup.Buttons("my_button")
  33.  
  34.     ' Remove an item by index
  35.     myGroup.Buttons.Remove 1
  36.  
  37.     ' Add the item back and remove it by object reference
  38.     myGroup.Buttons.Add myButton
  39.     ' Get another ref to the button
  40.     Dim myButton4 As rxButton
  41.     Set myButton4 = myGroup.Buttons("my_button")
  42.     ' Remove
  43.     myGroup.Buttons.Remove myButton4
  44.  
  45. End Sub

C#

  1.  

VB.NET

  1.  

C++

  1.