# SetExpanded

> Set a single TreeViewItem to be expanded or collapsed.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor.IMGUI.Controls](/engine/6000.3/script-reference/unityeditor/imgui/controls.md)
* **Assembly:** UnityEditor

## SetExpanded(T, bool)

Set a single TreeViewItem to be expanded or collapsed.

```csharp
public bool SetExpanded(TIdentifier id, bool expanded)
```

### Parameters

**** (T): TreeViewItem ID.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): True expands item. False collapses item.

### Returns

| Type                                                          | Description                                                                          |
| ------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if item changed expanded state, false if item already had the `expanded` state. |

## SetExpanded(IList\<T>)

Set the current expanded TreeViewItems of the TreeView. This will overwrite the previous expanded state.

```csharp
public void SetExpanded(IList<TIdentifier> ids)
```

### Parameters

**** (\[IList\<T>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.ilist-1)): List of item IDs that should be expanded.
