Version

ExtractExistingElement(ArrayList,Type,Boolean) Method

Static method that searches thru the passed in collection and returns the first object of the requested type that it finds
Syntax
'Declaration
 
Protected Overloads Shared Function ExtractExistingElement( _
   ByVal existingElements As ArrayList, _
   ByVal type As Type, _
   ByVal removeExtractedElement As Boolean _
) As Object
protected static object ExtractExistingElement( 
   ArrayList existingElements,
   Type type,
   bool removeExtractedElement
)

Parameters

existingElements
Collection to search
type
Type of element to locate
removeExtractedElement
True to remove the element from the arraylist. The size of the arraylist will remain constant.

Return Value

The first object of the requested type that is found int he passed in collection.
Example
This sample uses ExtractExistingElement to re-use an existing button element.

Imports Infragistics.Win
Imports  System.Collections

Private Function GetButtonElement(ByVal childElementsCollection As ArrayList) As Infragistics.Win.ButtonUIElement

       ' Check ChildElements collection to see if
       ' there is a button UIElement that can be used.
       Dim btn As ButtonUIElement = ExtractExistingElement(childElementsCollection, GetType(ButtonUIElement), True)
 
       ' If not button will be nothing in which case we will instantiate a new one.
       If btn Is Nothing Then
           btn = New ButtonUIElement(Me)
       End If

       Return btn

   End Function
using Infragistics.Win;
using  System.Collections;

private Infragistics.Win.ButtonUIElement GetButtonElement(System.Collections.ArrayList childElementsCollection)
{

	// Check ChildElements collection to see if
	// there is a button UIElement that can be used.
	Infragistics.Win.ButtonUIElement button = ExtractExistingElement(childElementsCollection, typeof(Infragistics.Win.ButtonUIElement),true) as Infragistics.Win.ButtonUIElement ;


	// If not button will be null in which case we will instantiate a new one.
	if(null == button)
		button = new Infragistics.Win.ButtonUIElement(this);

	return button;

}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also