Windows form templates visual studio

Step 1: Create a Windows Forms App project

When you create a picture viewer, the first step is to create a Windows Forms App project.

Open Visual Studio 2017

On the menu bar, choose File > New > Project. The dialog box should look similar to the following screenshot.


New project dialog box

On the left side of the New Project dialog box, choose either Visual C# or Visual Basic, and then choose Windows Desktop.

In the project templates list, choose Windows Forms App (.NET Framework). Name the new form PictureViewer, and then choose the OK button.

If you don’t see the Windows Forms App (.NET Framework) template, use the Visual Studio Installer to install the .NET desktop development workload.

For more information, see the Install Visual Studio page.

Open Visual Studio 2019

On the start window, choose Create a new project.

On the Create a new project window, enter or type Windows Forms in the search box. Next, choose Desktop from the Project type list.

After you apply the Project type filter, choose the Windows Forms App (.NET Framework) template for either C# or Visual Basic, and then choose Next.

If you don’t see the Windows Forms App (.NET Framework) template, you can install it from the Create a new project window. In the Not finding what you’re looking for? message, choose the Install more tools and features link.

Next, in the Visual Studio Installer, choose the Choose the .NET desktop development workload.

After that, choose the Modify button in the Visual Studio Installer. You might be prompted to save your work; if so, do so. Next, choose Continue to install the workload.

In the Configure your new project window, type or enter PictureViewer in the Project name box. Then, choose Create.

Visual Studio creates a solution for your app. A solution acts as a container for all of the projects and files needed by your app. These terms will be explained in more detail later in this tutorial.

About the Windows Forms App project

The development environment contains three windows: a main window, Solution Explorer, and the Properties window.

If any of these windows are missing, you can restore the default window layout. On the menu bar, choose Window > Reset Window Layout.

You can also display windows by using menu commands. On the menu bar, choose View > Properties Window or Solution Explorer.

If any other windows are open, close them by choosing the Close (x) button in their upper-right corners.

  • Main window In this window, you’ll do most of your work, such as working with forms and editing code. The window shows a form in the Form Editor. At the top of the window, the Start Page tab and the Form1.cs [Design] tab appear. (In Visual Basic, the tab name ends with .vb instead of .cs.)
  • Main window In this window, you’ll do most of your work, such as working with forms and editing code. The window shows a form in the Form Editor.
  • Solution Explorer window In this window, you can view and navigate to all items in your solution.

If you choose a file, the contents of the Properties window changes. If you open a code file (which ends in .cs in C# and .vb in Visual Basic), the code file or a designer for the code file appears. A designer is a visual surface onto which you can add controls such as buttons and lists. For Visual Studio forms, the designer is called the Windows Forms Designer.

Properties window In this window, you can change the properties of items that you choose in the other windows. For example, if you choose Form1, you can change its title by setting the Text property, and you can change the background color by setting the Backcolor property.

The top line in Solution Explorer shows Solution ‘PictureViewer’ (1 project), which means that Visual Studio created a solution for you. A solution can contain more than one project, but for now, you’ll work with solutions that contain only one project.

On the menu bar, choose File > Save All.

As an alternative, choose the Save All button on the toolbar, which the following image shows.

Save All toolbar button

Visual Studio automatically fills in the folder name and the project name and then saves the project in your projects folder.

Next steps

To go to the next tutorial step, see Step 2: Run your app.

To return to the overview topic, see Tutorial 1: Create a picture viewer.

Шаблоны проектов и элементов Visual Studio для приложений для Windows Visual Studio project and item templates for Windows apps

Visual Studio 2019 предоставляет множество шаблонов проектов и элементов. Такие шаблоны помогают создавать приложения для устройств с Windows 10 на C# или C++. Visual Studio 2019 provides many project and item templates that help you build apps for Windows 10 devices by using C# or C++. В этом разделе описаны шаблоны и приведены рекомендации по выбору одного из них для вашего сценария. This topic describes the templates and helps you choose one for your scenario.

  • К шаблонам проектов относятся файлы проекта, файлы кода и другие ресурсы, настроенные для создания приложения или компонента, которые может загрузить и использовать приложение. Project templates include project files, code files, and other assets that are configured to build an app or a component that can be loaded and used by an app.
  • Шаблоны элементов — это файлы проекта, которые содержат часто используемые код и XAML, которые можно добавить в проект, чтобы ускорить разработку. Item templates are project files that contain commonly used code and XAML that can be added to a project to reduce development time. Например, с помощью шаблона элемента можно добавить в приложение новое окно, страницу или элемент управления. For example, you can use an item template to add a new window, page, or control to your app.
Читайте также:  Цветной терминал mac os

Шаблоны WinUI WinUI templates

Библиотека пользовательского интерфейса Windows (WinUI) — это современная нативная платформа пользовательского интерфейса, поддерживаемая приложениями для Windows, как классическими (.NET и нативные приложения Win32), так и приложениями UWP. The Windows UI Library (WinUI) is the modern native user interface (UI) platform for Windows apps across desktop (.NET and native Win32) and UWP app platforms. WinUI 3 — это последняя основная версия WinUI. Это полноценная платформа пользовательского интерфейса для классических приложений для Windows. WinUI 3 is the latest major version of WinUI, and it transforms WinUI into a full UX framework for desktop Windows apps.

WinUI 3 доступна в составе Project Reunion. WinUI 3 is available as part of Project Reunion. Она включает пакет VSIX для Visual Studio 2019 с шаблонами проектов и элементов, которые помогут приступить к созданию приложений с помощью интерфейса на основе WinUI. It includes a VSIX package for Visual Studio 2019 that provides project and item templates that help you get started building apps with a WinUI-based interface.

Инструкции по установке пакета VSIX для Project Reunion и шаблонов проектов WinUI см. в разделе Настройка среды разработки. For instructions to install the Project Reunion VSIX package and the WinUI project templates, see Set up your development environment. Дополнительные сведения о доступных шаблонах проектов и элементов WinUI см. в разделе Создание проектов WinUI 3. For more information about the available WinUI project and item templates, see Create WinUI 3 projects.

Шаблоны UWP UWP templates

Visual Studio предоставляет разнообразные шаблоны проектов для создания приложений UWP с помощью C# или C++. Visual Studio provides a variety of project templates for building UWP apps with C# or C++. Чтобы использовать эти шаблоны проектов, при установке Visual Studio необходимо включить рабочую нагрузку Разработка приложений для универсальной платформы Windows. To use these project templates, you must include the Universal Windows Platform development workload when you install Visual Studio. Для шаблонов проектов C++ также необходимо включить дополнительный компонент средств универсальной платформы Windows C++ (v142) для рабочей нагрузки Разработка приложений для универсальной платформы Windows. For the C++ project templates, you must also include the C++ (v142) Universal Windows Platforms tools optional component for the Universal Windows Platform development workload.

Шаблоны проектов для C# и UWP Project templates for C# and UWP

Чтобы получить доступ к шаблонам проектов UWP C#, когда вы создаете проект в Visual Studio, отфильтруйте язык, выбрав C# , платформу, выбрав Windows, и тип проекта, выбрав значение UWP. To access the UWP C# project templates when you create a new project in Visual Studio, filter the language to C#, the platform to Windows, and the project type to UWP.

Эти шаблоны проектов можно использовать для создания приложений UWP на C#. You can use these project templates to create C# UWP apps.

Шаблон Template Описание Description
Пустое приложение (универсальные приложения для Windows) Blank App (Universal Windows) Создает приложение UWP. Creates a UWP app. Созданный проект содержит базовую страницу, производную от класса Windows.UI.Xaml.Controls.Page, с помощью которой можно приступить к созданию пользовательского интерфейса. The generated project includes a basic page that derives from the Windows.UI.Xaml.Controls.Page class that you can use to start building your UI.
Приложение модульных тестов (универсальное приложение для Windows) Unit Test App (Universal Windows) Создает проект модульного теста на C# для приложения UWP. Creates a unit test project in C# for a UWP app. Дополнительные сведения см. в статье Модульное тестирование кода C#. For more information, see Unit test C# code.

С помощью этих шаблонов проектов можно создавать фрагменты приложений UWP на C#. You can use these project templates to build pieces of a C# UWP app.

Шаблон Template Описание Description
Библиотека классов (универсальные приложения для Windows) Class Library (Universal Windows) Создает управляемую библиотеку классов (DLL) на языке C#, которую могут использовать другие приложения UWP, написанные с применением управляемого кода. Creates a managed class library (DLL) in C# that can be used by other UWP apps written in managed code.
Компонент среды выполнения Windows (универсальные приложения для Windows) Windows Runtime Component (Universal Windows) Создает компонент среды выполнения Windows на C#, который может использоваться в любом приложении UWP, независимо от того, на каком языке программирования такое приложение написано. Creates a Windows Runtime component in C# that can be consumed by any UWP app, regardless of the programming language in which the app is written.
Необязательный пакет кода (универсальные приложения для Windows) Optional Code Package (Universal Windows) Создает дополнительный пакет с исполняемым кодом C#, который может загрузить приложение. Creates an optional package with executable C# code that can be loaded by an app. Подробные сведения см. в статье Дополнительные пакеты с исполняемым кодом. For more information, see Optional packages with executable code.

Шаблоны проектов для C++ и UWP Project templates for C++ and UWP

Для создания приложений UWP можно использовать две технологии C++: There are two different technologies you can use to build C++ UWP apps:

  • Рекомендуемая технология — C++/WinRT. The recommended technology is C++/WinRT. Это проекция языка C++, которая полностью реализована в файлах заголовков и предназначена для предоставления эффективного и удобного доступа к современному API WinRT. This is a C++ language projection that is implemented entirely in header files, and designed to provide you with first-class access to the modern WinRT API.
  • Кроме того, можно использовать более старый набор расширений C++/CX. Alternatively, you can use the older C++/CX set of extensions. C++/CX по-прежнему поддерживается, но мы рекомендуем вместо него использовать C++/WinRT. C++/CX is still supported, but we recommend that you use C++/WinRT instead.

Чтобы получить доступ к шаблонам проектов UWP C++, когда вы создаете проект в Visual Studio, отфильтруйте язык, выбрав C++ , платформу, выбрав Windows, и тип проекта, выбрав значение UWP. To access the UWP C++ project templates when you create a new project in Visual Studio, filter the language to C++, the platform to Windows, and the project type to UWP.

По умолчанию рабочая нагрузка Разработка приложений для универсальной платформы Windows в Visual Studio предоставляет доступ только к шаблонам проектов C++/CX. By default, the Universal Windows Platform development workload in Visual Studio only provides access to the C++/CX project templates. Чтобы получить доступ к шаблонам проектов C++/WinRT, необходимо установить пакет VSIX C++/WinRT. To access the C++/WinRT project templates, you must install the C++/WinRT VSIX package.

Эти шаблоны проектов можно использовать для создания приложений UWP на C++. You can use these project templates to create C++ UWP apps.

Шаблон Template Описание Description
Пустое приложение (C++/WinRT) Blank App (C++/WinRT) Создает приложение UWP C++/WinRT с пользовательским интерфейсом XAML. Creates a C++/WinRT UWP app with a XAML user interface. Созданный проект содержит базовую страницу, производную от класса Windows.UI.Xaml.Controls.Page, с помощью которой можно приступить к созданию пользовательского интерфейса. The generated project includes a basic page that derives from the Windows.UI.Xaml.Controls.Page class that you can use to start building your UI.
Приложение основных компонентов (C++/WinRT) Core App (C++/WinRT) Создает приложение UWP C++/WinRT, которое использует CoreApplication для интеграции с различными платформами пользовательского интерфейса вместо пользовательского интерфейса XAML. Creates a C++/WinRT UWP app that uses CoreApplication to integrate with a variety of UI frameworks instead of a XAML user interface. См. пошаговые инструкции по созданию с помощью этого шаблона проекта простой игры UWP, использующей DirectX. For a walkthrough that demonstrates how to use this project template to create a simple game that uses DirectX, see Create a simple UWP game with DirectX.
Пустое приложение (универсальное приложение для Windows — C++/CX) Blank App (Universal Windows — C++/CX) Создает приложение UWP C++/WinRT с пользовательским интерфейсом XAML. Creates a C++/WinRT UWP app with a XAML user interface. Созданный проект содержит в библиотеке WinUI базовую страницу, производную от класса Windows.UI.Xaml.Controls.Page, с помощью которой можно приступить к созданию пользовательского интерфейса. The generated project includes a basic page that derives from the Windows.UI.Xaml.Controls.Page class in the WinUI library that you can use to start building your UI.
Приложение DirectX 11 и XAML (универсальное приложение для Windows — C++/CX) DirectX 11 and XAML App (Universal Windows — C++/CX) Создает приложение UWP, которое использует DirectX 11 и SwapChainPanel, чтобы можно было использовать элементы управления пользовательского интерфейса XAML. Creates a UWP app that uses DirectX 11 and a SwapChainPanel so you can use XAML UI controls. Дополнительные сведения см. в статье Шаблоны проектов игр DirectX. For more information, see DirectX game project templates.
Приложение DirectX 11 (универсальное приложение для Windows — C++/CX) DirectX 11 App (Universal Windows — C++/CX) Создает приложение UWP, которое использует DirectX 11. Creates a UWP app that uses DirectX 11. Дополнительные сведения см. в статье Шаблоны проектов игр DirectX. For more information, see DirectX game project templates.
Приложение DirectX 12 (универсальное приложение для Windows — C++/CX) DirectX 12 App (Universal Windows — C++/CX) Создает приложение UWP, которое использует DirectX 12. Creates a UWP app that uses DirectX 12. Дополнительные сведения см. в статье Шаблоны проектов игр DirectX. For more information, see DirectX game project templates.
Приложение модульных тестов (универсальное приложение для Windows — C++/CX) Unit Test App (Universal Windows — C++/CX) Создает проект модульного теста в C++/CX для приложения UWP. Creates a unit test project in C++/CX for a UWP app. Дополнительные сведения см. в статье о тестировании DLL-библиотеки C++ UWP. For more information, see How to test a C++ UWP DLL.

С помощью этих шаблонов проектов можно создавать фрагменты приложений UWP на C++. You can use these project templates to build pieces of a C++ UWP app.

Шаблон Template Описание Description
Компонент среды выполнения Windows (C++/WinRT) Windows Runtime Component (C++/WinRT) Создает компонент среды выполнения Windows на C++/WinRT, который может использоваться в любом приложении UWP, независимо от того, на каком языке программирования такое приложение написано. Creates a Windows Runtime component in C++/WinRT that can be consumed by any UWP app, regardless of the programming language in which the app is written.
Компонент среды выполнения Windows (универсальные приложения для Windows) Windows Runtime Component (Universal Windows) Создает компонент среды выполнения Windows на C++/CX, который может использоваться в любом приложении UWP, независимо от того, на каком языке программирования такое приложение написано. Creates a Windows Runtime component in C++/CX that can be consumed by any UWP app, regardless of the programming language in which the app is written.
Библиотека DLL (универсальные приложения для Windows) DLL (Universal Windows) Проект для создания библиотеки динамической компоновки (DLL), которую можно использовать в приложении UWP, на C++/CX. A project for creating a dynamic-link library (DLL) in C++/CX that can be used in a UWP app. Дополнительные сведения см. в статье Библиотеки DLL (C++/CX). For more information, see DLLs (C++/CX).
Статическая библиотека (универсальные приложения для Windows) Static Library (Universal Windows) Проект для создания статической библиотеки (LIB), которую можно использовать в приложении UWP, на C++/CX. A project for creating a static library (LIB) in C++/CX that can be used in a UWP app. Дополнительные сведения см. в статье Статические библиотеки (C++/CX). For more information, see Static libraries (C++/CX).

Шаблоны C++/Win32 C++/Win32 templates

Visual Studio предоставляет разнообразные шаблоны проектов для создания классических приложений для Windows с использованием нативного C++ и прямым доступом к API Win32. Visual Studio provides a variety of project templates for building desktop Windows apps with native C++ and direct access to the Win32 API. Чтобы использовать эти шаблоны проектов, при установке Visual Studio необходимо включить рабочую нагрузку Разработка классических приложений на C++ . To use these project templates, you must include the Desktop development with C++ workload when you install Visual Studio. Эта рабочая нагрузка включает шаблоны проектов для создания классических и консольных приложений, а также библиотек. This workload includes project templates for building desktop apps, console apps, and libraries.

Шаблоны проектов для классических приложений Project templates for desktop apps

Чтобы получить доступ к шаблонам проектов C++ для классических приложений, когда вы создаете проект в Visual Studio, отфильтруйте язык, выбрав C++ , платформу, выбрав Windows, и тип проекта, выбрав значение Desktop (Классическое приложение). To access the C++ project templates for classic desktop apps when you create a new project in Visual Studio, filter the language to C++, the platform to Windows, and the project type to Desktop.

Шаблон Template Описание Description
Классическое приложение для Windows Windows Desktop Application Создает классическое приложение для Windows с использованием C++. Creates a classic Windows desktop app with C++. Дополнительные сведения см. в статье Пошаговое руководство. Создание традиционного классического приложения для Windows (C++). For more information, see Walkthrough: Create a traditional Windows Desktop application.
Мастер классических приложений Windows Windows Desktop Wizard Это пошаговый мастер, с помощью которого можно создать один из следующих типов проектов: классическое приложение для Windows, консольное приложение, библиотека динамической компоновки (DLL) или статическая библиотека. Provides a step-by-step wizard you can use to create one of the following types of projects: a classic Windows desktop app, a console app, a dynamic-link library (DLL), or a static library. Дополнительные сведения см. в статьях Мастер классических приложений Windows и Пошаговое руководство. Создание традиционного классического приложения для Windows (C++). For more information, see Windows Desktop Wizard and Walkthrough: Create a traditional Windows Desktop application.
Проект упаковки приложений Windows Windows Application Packaging Project Создает проект, с помощью которого можно разработать классическое приложение в пакете MSIX. Creates a project that you can use to build a desktop app into an MSIX package. Благодаря этому пользователь получает современные методы развертывания, возможности интеграции с компонентами Windows 10 через расширения пакетов и многое другое. This provides a modern deployment experience, the ability to integrate with Windows 10 features via package extensions, and much more. Дополнительные сведения см. в статье о Проекте упаковки приложений Windows. For more information, see Windows Application Packaging Project.

Шаблоны проектов для консольных приложений Project templates for console apps

Чтобы получить доступ к шаблонам проектов C++ для консольных приложений, отфильтруйте язык, выбрав C++ , платформу, выбрав Windows, и тип проекта, выбрав значение Console (Консольное приложение). To access the C++ project templates for console apps, filter the language to C++, the platform to Windows, and the project type to Console.

Шаблон Template Описание Description
Консольное приложение для Windows (C++/WinRT) Windows Console Application (C++/WinRT) Создает консольное приложение C++/WinRT без пользовательского интерфейса. Creates a C++/WinRT console app without a user interface. Дополнительные сведения см. в статье Краткое руководство по C++/WinRT. For more information, see C++/WinRT quick-start. Для этого шаблона проекта требуется VSIX C++/WinRT. This project template requires the C++/WinRT VSIX.
Консольное приложение Console App Создает консольное приложение без пользовательского интерфейса. Creates a console app without a user interface. Дополнительные сведения см. в статье Пошаговое руководство. Создание стандартной программы C++. For more information, see Walkthrough: Creating a Standard C++ Program.
Пустой проект Empty Project Пустой проект для создания приложения, библиотеки или DLL. An empty project for creating an application, library, or DLL. Необходимо добавить требуемый код или ресурсы. You must add any code or resources required.

Шаблоны проектов для библиотек Project templates for libraries

Чтобы получить доступ к шаблонам проектов C++ для библиотек, отфильтруйте язык, выбрав C++ , платформу, выбрав Windows, и тип проекта, выбрав значение Библиотека. To access the C++ project templates for libraries, filter the language to C++, the platform to Windows, and the project type to Library.

Шаблон Template Описание Description
Библиотека динамической компоновки (DLL) Dynamic-Link Library (DLL) Проект для создания библиотеки динамической компоновки (DLL). A project for creating a dynamic-link library (DLL). Дополнительные сведения см. в статье Пошаговое руководство. Создание и использование собственной библиотеки динамической компоновки (C++). For more information, see Walkthrough: Creating and using a dynamic link library.
Статическая библиотека Static Library Проект для создания статической библиотеки (LIB). A project for creating a static library (LIB). Дополнительные сведения см. в статье Пошаговое руководство. Создание и использование статической библиотеки. For more information, see Walkthrough: Create and use a static library.

Шаблоны элементов для нативного C++ и Win32 Item templates for native C++ and Win32

Шаблоны проектов C++ включают множество шаблонов элементов, с помощью которых можно выполнять такие задачи, как добавление в проект новых файлов и ресурсов. The C++ project templates for include many item templates that you can use to perform tasks like adding new files and resources to your project. Полный список см. в статье об использовании шаблонов Visual C++ в диалоговом окне «Добавление нового элемента». For a comprehensive list, see Using Visual C++ Add New Item Templates.

Шаблоны .NET .NET templates

Visual Studio предоставляет разнообразные шаблоны проектов для создания классических приложений для Windows, использующих .NET и C#. Visual Studio provides a variety of project templates for building desktop Windows apps that use .NET and C#. Чтобы использовать эти шаблоны проектов, при установке Visual Studio необходимо включить рабочую нагрузку Разработка классических приложений .NET. To use these project templates, you must include the .NET desktop development workload when you install Visual Studio.

Чтобы получить доступ к шаблонам проектов .NET C#, когда вы создаете проект в Visual Studio, отфильтруйте язык, выбрав C# , платформу, выбрав Windows, и тип проекта, выбрав Desktop (Классическое приложение). To access the .NET C# project templates when you create a new project in Visual Studio, filter the language to C#, the platform to Windows, and the project type to Desktop.

С помощью этих шаблонов проектов можно создавать приложения с использованием C# и .NET. You can use these project templates to create apps using C# and .NET.

Читайте также:  Linking libraries in linux
Оцените статью