ArcGIS Pro 2.8 API Reference Guide
InsertFavorite(Item,Int32) Method

ArcGIS.Desktop.Core Namespace > FavoritesManager Class > InsertFavorite Method : InsertFavorite(Item,Int32) Method
The item to add to the favorite collection. For example a folder connection or a toolbox.
The index at which the item is to be inserted.
Inserts an item to the favorites collection. The item is added to the collection with the Favorite.IsAddedToAllNewProjects value set to false.
Syntax
public Favorite InsertFavorite( 
   Item item,
   int index
)
Public Overloads Function InsertFavorite( _
   ByVal item As Item, _
   ByVal index As Integer _
) As Favorite

Parameters

item
The item to add to the favorite collection. For example a folder connection or a toolbox.
index
The index at which the item is to be inserted.

Return Value

The favorite item. Null if the item cannot be added as a favorite.
Remarks
An item can only exist once in the favorite collection. If the item already exists in the favorites collection, then no additional item is inserted. However the existing item will be moved to the specified index and the Favorite.IsAddedToAllNewProjects property will be updated to false.

You should always check CanAddAsFavorite before passing an item to this method.

Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

FavoritesManager Class
FavoritesManager Members
Overload List