Skip to content

Combine WinForms controls label topics with designer topics #13876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions .openpublishing.redirection.json
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@
"source_path": "docs/framework/configure-apps/file-schema/wcf/udpannoucementendpoint.md",
"redirect_url": "/dotnet/framework/configure-apps/file-schema/wcf/udpannouncementendpoint",
"redirect_document_id": true
},
},
{
"source_path": "docs/framework/data/adonet/ef/language-reference/csdl-specification.md",
"redirect_url": "/ef/ef6/modeling/designer/advanced/edmx/csdl-spec"
Expand Down Expand Up @@ -2189,6 +2189,21 @@
"source_path": "docs/framework/winforms/advanced/walkthrough-changing-properties-of-a-hosted-wpf-element-at-design-time.md",
"redirect_url": "/previous-versions/visualstudio/visual-studio-2010/bb384330(v=vs.100)"
},
{
"source_path": "docs/framework/winforms/controls/how-to-create-access-keys-for-windows-forms-controls-using-the-designer.md",
"redirect_url": "/dotnet/framework/winforms/controls/how-to-create-access-keys-for-windows-forms-controls",
"redirect_document_id": false
},
{
"source_path": "docs/framework/winforms/controls/how-to-set-the-text-displayed-by-a-windows-forms-control-using-the-designer.md",
"redirect_url": "/dotnet/framework/winforms/controls/how-to-set-the-text-displayed-by-a-windows-forms-control",
"redirect_document_id": false
},
{
"source_path": "docs/framework/winforms/controls/how-to-set-the-image-displayed-by-a-windows-forms-control-using-the-designer.md",
"redirect_url": "/dotnet/framework/winforms/controls/how-to-set-the-image-displayed-by-a-windows-forms-control",
"redirect_document_id": false
},
{
"source_path": "docs/framework/winforms/controls/99f6e876-3f7f-4139-9063-e36587c95b02.md",
"redirect_url": "/dotnet/framework/winforms/controls/create-a-master-detail-form-using-two-datagridviews",
Expand Down Expand Up @@ -2349,7 +2364,7 @@
"redirect_document_id": true
},
{

"source_path": "docs/machine-learning/how-to-guides/determine-global-feature-importance-in-model.md",
"redirect_url": "/dotnet/machine-learning/how-to-guides/explain-machine-learning-model-permutation-feature-importance-ml-net",
"redirect_document_id":true
Expand Down Expand Up @@ -2406,7 +2421,7 @@
{
"source_path": "docs/machine-learning/resources/what-is-mldotnet.md",
"redirect_url": "/dotnet/machine-learning/how-does-mldotnet-work"
},
},
{
"source_path": "docs/machine-learning/basic-concepts-model-training-in-mldotnet.md",
"redirect_url": "/dotnet/machine-learning/how-does-mldotnet-work",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
title: "How to: Create Access Keys for Windows Forms Controls"
ms.date: "03/30/2017"
dev_langs:
ms.date: 08/20/2019
dev_langs:
- "csharp"
- "vb"
- "cpp"
helpviewer_keywords:
helpviewer_keywords:
- "controls [Windows Forms], access keys"
- "Button control [Windows Forms], access keys"
- "dialog box controls [Windows Forms], mnemonics"
Expand All @@ -21,31 +21,38 @@ helpviewer_keywords:
- "ALT key"
ms.assetid: 4faa0991-28ec-4eca-91db-51dc2cd6a7ac
---
# How to: Create Access Keys for Windows Forms Controls
An *access key* is an underlined character in the text of a menu, menu item, or the label of a control such as a button. With an access key, the user can "click" a button by pressing the ALT key in combination with the predefined access key. For example, if a button runs a procedure to print a form, and therefore its `Text` property is set to "Print," adding an ampersand before the letter "P" causes the letter "P" to be underlined in the button text at run time. The user can run the command associated with the button by pressing ALT+P. You cannot have an access key for a control that cannot receive focus.

### To create an access key for a control

1. Set the `Text` property to a string that includes an ampersand (&) before the letter that will be the shortcut.

```vb
' Set the letter "P" as an access key.
Button1.Text = "&Print"
```

```csharp
// Set the letter "P" as an access key.
button1.Text = "&Print";
```

```cpp
// Set the letter "P" as an access key.
button1->Text = "&Print";
```

> [!NOTE]
> To include an ampersand in a caption without creating an access key, include two ampersands (&&). A single ampersand is displayed in the caption and no characters are underlined.

# How to: Create access keys for Windows Forms controls

An *access key* is an underlined character in the text of a menu, menu item, or the label of a control such as a button. With an access key, the user can "click" a button by pressing the Alt key in combination with the predefined access key. For example, if a button runs a procedure to print a form, and therefore its `Text` property is set to "Print," adding an ampersand before the letter "P" causes the letter "P" to be underlined in the button text at run time. The user can run the command associated with the button by pressing Alt+P.

Controls that cannot receive focus can't have access keys.

## Programmatic

Set the `Text` property to a string that includes an ampersand (&) before the letter that will be the shortcut.

```vb
' Set the letter "P" as an access key.
Button1.Text = "&Print"
```

```csharp
// Set the letter "P" as an access key.
button1.Text = "&Print";
```

```cpp
// Set the letter "P" as an access key.
button1->Text = "&Print";
```

> [!NOTE]
> To use an ampersand in a caption without creating an access key, include two ampersands (&&). A single ampersand is displayed in the caption and no characters are underlined.

## Designer

In the **Properties** window of Visual Studio, set the **Text** property to a string that includes an ampersand ('&') before the letter that will be the access key. For example, to set the letter "P" as the access key, enter **&Print**.

## See also

- <xref:System.Windows.Forms.Button>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "How to: Set the Image Displayed by a Windows Forms Control"
ms.date: "03/30/2017"
ms.date: 08/20/2019
dev_langs:
- "csharp"
- "vb"
Expand All @@ -15,41 +15,44 @@ ms.assetid: 9445af8f-4f62-48b0-a3f6-068058964b9f
---
# How to: Set the image displayed by a Windows Forms control

Several Windows Forms controls can display images. These images can be icons that clarify the purpose of the control, such as a diskette icon on a button denoting the **Save** command. Alternatively, the icons can be background images to give the control the appearance and behavior you want.

## To set the image displayed by a control

1. Set the control's `Image` or `BackgroundImage` property to an object of type <xref:System.Drawing.Image>. Generally, you will be loading the image from a file by using the <xref:System.Drawing.Image.FromFile%2A> method.

In the following code example, the path set for the location of the image is the **My Pictures** folder. Most computers running the Windows operating system will include this directory. This also enables users with minimal system access levels to run the application safely. The following code example requires that you already have a form with a <xref:System.Windows.Forms.PictureBox> control added.

```vb
' Replace the image named below
' with an icon of your own choosing.
PictureBox1.Image = Image.FromFile _
(System.Environment.GetFolderPath _
(System.Environment.SpecialFolder.MyPictures) _
& "\Image.gif")
```

```csharp
// Replace the image named below
// with an icon of your own choosing.
// Note the escape character used (@) when specifying the path.
pictureBox1.Image = Image.FromFile
(System.Environment.GetFolderPath
(System.Environment.SpecialFolder.MyPictures)
+ @"\Image.gif");
```

```cpp
// Replace the image named below
// with an icon of your own choosing.
pictureBox1->Image = Image::FromFile(String::Concat
(System::Environment::GetFolderPath
(System::Environment::SpecialFolder::MyPictures),
"\\Image.gif"));
```
Several Windows Forms controls can display images. These images can be icons that clarify the purpose of the control, such as a diskette icon on a button denoting the Save command. Alternatively, the icons can be background images to give the control the appearance and behavior you want.

## Programmatic

Set the control's `Image` or `BackgroundImage` property to an object of type <xref:System.Drawing.Image>. Generally, you'll be loading the image from a file by using the <xref:System.Drawing.Image.FromFile%2A> method.

In the following code example, the path set for the location of the image is the **My Pictures** folder. Most computers running the Windows operating system include this directory. This also enables users with minimal system access levels to run the application safely. The following code example requires that you already have a form with a <xref:System.Windows.Forms.PictureBox> control added.

```vb
' Replace the image named below with your own icon.
PictureBox1.Image = Image.FromFile _
(System.Environment.GetFolderPath _
(System.Environment.SpecialFolder.MyPictures) _
& "\Image.gif")
```

```csharp
// Replace the image named below with your own icon.
// Note the escape character used (@) when specifying the path.
pictureBox1.Image = Image.FromFile
(System.Environment.GetFolderPath
(System.Environment.SpecialFolder.MyPictures)
+ @"\Image.gif");
```

```cpp
// Replace the image named below with your own icon.
pictureBox1->Image = Image::FromFile(String::Concat
(System::Environment::GetFolderPath
(System::Environment::SpecialFolder::MyPictures),
"\\Image.gif"));
```

## Designer

1. In the **Properties** window of Visual Studio, select the **Image** or **BackgroundImage** property of the control, and then select the ellipsis (![Ellipsis button in Visual Studio](./media/visual-studio-ellipsis-button.png)) to display the **Select Resource** dialog box.

2. Select the image you want to display.

## See also

Expand Down

This file was deleted.

Loading