Share via


XRObservableCollection.InsertItemImpl(int,XRValue *) (Compact 7)

3/12/2014

This protected method implements collection operations that add items to the data source collection and invokes XRObservableCollection.OnCollectionChanged(XRCollectionChangedCustomEventArgs *) to send an event notification that the collection has changed.

Syntax

HRESULT STDMETHODCALLTYPE InsertItemImpl(
int nIndex,
XRValue * pValue)

Parameters

  • nIndex
    [in] The index of the collection location where the XRValue object is inserted.
  • pValue
    [in] A pointer to the XRValue object to insert into the collection.

Return Value

The following table shows the possible return values.

Value Description

S_OK

The method was successful.

E_FAIL

The method was unsuccessful.

E_BUSY

The collection is currently being updated.

E_OUTOFMEMORY

The method exceeded its available memory.

E_POINTER

The pValue parameter cannot be converted to an XRObject<Base> instance.

The E_OUTOFMEMORY value is returned when the system does not have enough memory to create an object instance.

The E_OUTOFMEMORY and E_FAIL values are returned in two different situations:

  • E_OUTOFMEMORY is returned if the method was able to process the internal input parameter for the internal call to create an instance; however, the method was unable to create the instance by using the input parameter.
  • E_FAIL is returned by the method’s internal call to create an instance if none of its if statements were evaluated by the method. When E_FAIL is returned, none of the code in the internal call to create an instance was processed.

Remarks

The inherited method XRValueCollectionT.Insert(int,const ItemType&) internally calls the InsertItemImpl method to execute the functionality to add an item to the data source collection. You can override this method to provide a customized implementation of adding items to the collection.

Because XRObservableCollection.InsertItemImpl is a protected member, an instance of XRObservableCollection<ItemType> cannot directly access the XRObservableCollection.InsertItemImpl method.

If you derive a new class from XRObservableCollection<ItemType> that uses either public or protected access modifiers, you can override this method in the new class.

Requirements

Header

XRCollection.h,
XRCustomEvent.h

See Also

Reference

XRObservableCollection<ItemType>