--- title: "How to: Access Keyed Collections" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "keyed collections [Windows Forms]" - "collections [Windows Forms], accessing with keys" ms.assetid: b9b79b8b-d9bf-4f8c-b9d6-9578bc3219d3 --- # How to: Access Keyed Collections in Windows Forms - You can access individual collection items by key. This functionality has been added to many collection classes that are typically used by Windows Forms applications. The following list shows some of the collection classes that have accessible keyed collections: - - - - - The key associated with an item in a collection is typically the name of the item. The following procedures show you how to use collection classes to perform common tasks. ### To find and give focus to a nested control in a control collection - Use the and methods to specify the name of the control to find and give focus to. [!code-csharp[System.Windows.Forms.KeyedCollectionsEx#1](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.KeyedCollectionsEx/CS/Form1.cs#1)] [!code-vb[System.Windows.Forms.KeyedCollectionsEx#1](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.KeyedCollectionsEx/VB/Form1.vb#1)] ### To access an image in an image collection - Use the property to specify the name of the image you want to access. [!code-csharp[System.Windows.Forms.KeyedCollectionsEx#2](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.KeyedCollectionsEx/CS/Form1.cs#2)] [!code-vb[System.Windows.Forms.KeyedCollectionsEx#2](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.KeyedCollectionsEx/VB/Form1.vb#2)] ### To set a tab page as the selected tab - Use the property together with the property to specify the name of the tab page to set as the selected tab. [!code-csharp[System.Windows.Forms.KeyedCollectionsEx#3](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.KeyedCollectionsEx/CS/Form1.cs#3)] [!code-vb[System.Windows.Forms.KeyedCollectionsEx#3](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.KeyedCollectionsEx/VB/Form1.vb#3)] ## See also - [Getting Started with Windows Forms](getting-started-with-windows-forms.md) - [How to: Add or Remove Images with the Windows Forms ImageList Component](./controls/how-to-add-or-remove-images-with-the-windows-forms-imagelist-component.md)