PreviousDTO Programmer's Guide (9.1 revision 1) Next

DtoSelectionItems Collection

Show this topic in Library frames

A collection of DtoSelectionItem objects representing the possible values of a selection type setting.

Properties

Count
Returns the number of members in a collection.
Item
Returns a specific member of a collection.

Methods
Add method 
GetById method 
Remove method 
Remarks

The property AllPossibleSelections of object DtoSetting Object returns the DtoSelectionItems collection.

Use the Count property to find the number of members in the collection.

Example
Set first_setting = my_settings(1) 
type = first_setting.Type 
' only call this for selection type settings 
' see Setting Type enumeration 
' for a list of setting types 
if (type = dtoSingleSel) OR (type = dtoMultiSel) 
Set all_the_selections = 
first_setting.AllPossibleSelections 
See Also

DtoCategories Collection
DtoSetting Object

Methods Detail

Add method

Add an item to a DtoSelectionItems collection.

Syntax
result = Collection.Add(Object) 
Arguments

Collection
DtoSelectionItems Collection to which to add object.
Object
A DtoSelectionItem object that you want to add.

Return Values

result
DtoResult long value indicating the result of the method call. Use the Error property of the DtoSession Object to obtain a description for the result.

Remarks

This method takes a parameter of type DtoSelectionItem. Therefore, you are responsible for first instantiating the object and setting its properties before adding it to the collection.

Example
Dim Result As dtoResult 
Dim Session As New DtoSession 
Result = Session.Connect("nik-ntws", "", "") 
Dim my_setting As DtoSetting 
Dim SetID As Long 
SetID = 26 
Set my_setting = Session.GetSetting(SetID) 
   If my_setting Is Nothing Then 
        MsgBox " Setting is wrong" 
        Exit Sub 
   End If 
' Start to assign new values: 
Dim new_selections As New DtoSelectionItems 
'Add Items with ItemID 1,2 and 12 
new_selections.Add 
my_setting.AllPossibleSelections.Item(2) 
   'Microsoft SPXII 
new_selections.Add 
my_setting.AllPossibleSelections.Item(4) 
   'Microsoft IPX 
new_selections.Add 
my_setting.AllPossibleSelections.Item(12) 
'Microsoft NETBIOS 
my_setting.Value = new_selections 

GetById method

Returns a DtoSelectionItem object from a DtoSelectionItems collection given an id.

Syntax
my_selection_item = Collection.GetById(id) 
Arguments

Collection
DtoSelectionItems collection
id
The id of the item you wish to retrieve from the collection. The id for a particular selection item can be obtained with the ItemId property of the DtoSelectionItem object.

Return Values

my_selection_item
DtoSelectionItem Object corresponding to id.

Example
Dim Result As DtoResult 
Dim Session As New DtoSession 
Result = Session.Connect("nik-ntws", "", "") 
Dim my_setting As DtoSetting 
Dim SetID As Long 
SetID = 26 
Set my_setting = Session.GetSetting(SetID) 
   If my_setting Is Nothing Then 
        MsgBox " Setting is wrong" 
        Exit Sub 
   End If 
Dim new_selections As New DtoSelectionItems 
new_selections.Add 
my_setting.AllPossibleSelections.GetByID(1)  
'Microsoft SPXII 
new_selections.Add 
my_setting.AllPossibleSelections.GetByID(3)  
'Microsoft TCP/IP 
new_selections.Add 
my_setting.AllPossibleSelections.GetByID(11) 
'Microsoft NETBIOS 
my_setting.Value = new_selections 

Remove method

Removes an item from a DtoSelectionItems collection

Syntax
result = Collection.Remove(item) 
Arguments

Collection
DtoSelectionItems collection
item
Variant that can contain the index (starting with 1) of the item you wish to remove from the collection or the name of the selection item.

Return Values

result
DtoResult long value indicating the result of the method call. Use the Error property of the DtoSession Object to obtain a description for the result.

Remarks

This method takes a parameter of type DtoSelectionItem

Example
Dim Result As DtoResult 
Dim Session As New DtoSession 
Result = Session.Connect("nik-ntws", "", "") 
Dim my_setting As DtoSetting 
Dim SetID As Long 
SetID = 26 
Set my_setting = Session.GetSetting(SetID) 
   If my_setting Is Nothing Then 
        MsgBox " Setting is wrong" 
        Exit Sub 
   End If 
Dim new_selections As New DtoSelectionItems 
new_selections.Add 
my_setting.AllPossibleSelections.GetByID(1)  
'Microsoft SPXII 
new_selections.Remove(1) 
my_setting.Value = new_selections 

Chapter contents
Publication contents

Prev topic: DtoSetting Object
Next topic: DtoSelectionItem Object