* Merge winforms framework content to working branch (#14) * Breadcrumb / TOC / Move net5 to net folder (#15) * change path from net5 to net * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Add .net 5 winforms placeholder article (#16) * added some metadata and adjusted net5 placeholder * corrections * corrections * corrections * Test1 * Swapping landing page vs concept * fix links * Fix links * Fix desc
3.0 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | ||||
|---|---|---|---|---|---|---|---|---|
| How to: Access Keyed Collections | 03/30/2017 |
|
|
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:
-
xref:System.Windows.Forms.ListViewItem.ListViewSubItemCollection
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 xref:System.Windows.Forms.Control.ControlCollection.Find%2A and xref:System.Windows.Forms.Control.Focus%2A methods to specify the name of the control to find and give focus to.
[!code-csharpSystem.Windows.Forms.KeyedCollectionsEx#1] [!code-vbSystem.Windows.Forms.KeyedCollectionsEx#1]
To access an image in an image collection
-
Use the xref:System.Windows.Forms.ImageList.ImageCollection.Item%2A property to specify the name of the image you want to access.
[!code-csharpSystem.Windows.Forms.KeyedCollectionsEx#2] [!code-vbSystem.Windows.Forms.KeyedCollectionsEx#2]
To set a tab page as the selected tab
-
Use the xref:System.Windows.Forms.TabControl.SelectedTab%2A property together with the xref:System.Windows.Forms.TabControl.TabPageCollection.Item%2A property to specify the name of the tab page to set as the selected tab.
[!code-csharpSystem.Windows.Forms.KeyedCollectionsEx#3] [!code-vbSystem.Windows.Forms.KeyedCollectionsEx#3]