---
title: "ListItemCollection..::.GetItemsByState Method "
canonical: https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_WinControls_ListItemCollection_GetItemsByState_3_4ff6e281.htm
product: "Graphics Mill 5.5 for .NET"
---

This documentation is for the old version. [Go to the latest Graphics Mill docs](https://www.graphicsmill.com/docs/gm/)

# ListItemCollection.GetItemsByState Method 
 
Gets an array of list items which have the specified state (e.g. checked, or selected).
 
**Namespace:** [Aurigma.GraphicsMill.WinControls](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_WinControls.htm.md)
 **Assembly:** Aurigma.GraphicsMill.WinControls (in Aurigma.GraphicsMill.WinControls.dll)
 
## Syntax
  
```
Public Function GetItemsByState ( _itemStateType As StateType, _valueToCompare As Boolean, _onlyFirst As Boolean _
) As IListItem()
```
 
```csharp
public IListItem[] GetItemsByState(StateType itemStateType,bool valueToCompare,bool onlyFirst
)
```
 
### Parameters
 
 - itemStateType
     - Type: [Aurigma.GraphicsMill.WinControls.StateType](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_WinControls_StateType.htm.md)
Member of the [StateType](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_WinControls_StateType.htm.md) enumeration specifying the search criteria.

 - valueToCompare
     - Type: [System.Boolean](http://msdn2.microsoft.com/en-us/a28wyd50)
A [Boolean](http://msdn2.microsoft.com/en-us/a28wyd50) value which should the state property have to be included into the result array.

 - onlyFirst
     - Type: [System.Boolean](http://msdn2.microsoft.com/en-us/a28wyd50)
A [Boolean](http://msdn2.microsoft.com/en-us/a28wyd50) value which specifies whether only the first found item should be returned (**true** ) or all items which meet *itemStateType* and *valueToCompare* arguments requirements (**false**).
 
### Return Value
Result array of list items that meets specified criterias.
 
## Remarks
  
This method checks [Checked](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_WinControls_IListItem_Checked.htm.md), [Focused](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_WinControls_IListItem_Focused.htm.md), or [Selected](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_WinControls_IListItem_Selected.htm.md) property (depending on the *itemStateType* argument value) of all items in the collection, and if it equals to *valueToCompare* argument, an appropriate item is added into the result array. For example, if you want to get all selected items, you should set *itemStateType* to [Selection](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_WinControls_StateType.htm.md) and *valueToCompare* to **true**. If you want to get, say, all unchecked items, use the following values: *itemStateType* = [Check](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_WinControls_StateType.htm.md) and *valueToCompare* = **false**.
   
## See Also

### Reference

- [ListItemCollection Class](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_WinControls_ListItemCollection.htm.md)
- [Aurigma.GraphicsMill.WinControls Namespace](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_WinControls.htm.md)
