コード例 #1
0
        /* Extended methods */

        /// <summary>
        /// Finds the index by item.
        /// </summary>
        /// <param name="control">The UI Automation element</param>
        /// <param name="matchString">The match string.</param>
        /// <returns>
        /// The zero-based index of the supplied item, or -1 if item is not found
        /// </returns>
        internal static int FindIndexByItem(AutomationElement control, string matchString)
        {
            AutomationElementCollection elementCollection = SelectionPatternHelper.GetListItems(control);

            for (int i = 0; i < elementCollection.Count; i++)
            {
                if (matchString == elementCollection[i].Current.Name)
                {
                    return(i);
                }
            }

            return(-1);
        }
コード例 #2
0
        /// <summary>
        /// Finds the item by zero-based index.
        /// </summary>
        /// <param name="control">The UI Automation element</param>
        /// <param name="index">The zero-based index of the item to select.</param>
        /// <returns>
        /// The item at the specified index
        /// </returns>
        internal static AutomationElement FindItemByIndex(AutomationElement control, int index)
        {
            AutomationElementCollection elementCollection = SelectionPatternHelper.GetListItems(control);

            return(elementCollection[index]);
        }