Dogodek
17. mar., 21h - 21. mar., 10h
Pridružite se nizu srečanj in ustvarite prilagodljive rešitve za AI na podlagi primerov uporabe v resničnem svetu s kolegi razvijalci in strokovnjaki.
Prijavite se zdajTa brskalnik ni več podprt.
Izvedite nadgradnjo na Microsoft Edge, če želite izkoristiti vse prednosti najnovejših funkcij, varnostnih posodobitev in tehnične podpore.
If your components are defined by a project in the currently open solution, they will automatically appear in the Toolbox, with no action required by you. You can also manually populate the Toolbox with your custom components by using the Choose Toolbox Items Dialog Box (Visual Studio), but the Toolbox takes account of items in your solution's build outputs with all the following characteristics:
Implements IComponent;
Does not have ToolboxItemAttribute set to false
;
Does not have DesignTimeVisibleAttribute set to false
.
Svarilo
This content was written for .NET Framework. If you're using .NET 6 or a later version, use this content with caution. The designer system has changed for Windows Forms and it's important that you review the Designer changes since .NET Framework article.
This walkthrough demonstrates how a custom component automatically appears in the Toolbox once the component is built. Tasks illustrated in this walkthrough include:
Creating a Windows Forms project.
Creating a custom component.
Creating an instance of a custom component.
Unloading and reloading a custom component.
When you are finished, you will see that the Toolbox is populated with a component that you have created.
Opomba
The Toolbox only displays components from libraries directly referenced by your project or components defined by a project in the solution.
In Visual Studio, create a Windows-based application project called ToolboxExample
(File > New > Project > Visual C# or Visual Basic > Classic Desktop > Windows Forms Application).
Add a new component to the project. Call it DemoComponent
.
For more information, see How to: Add New Project Items.
Build the project.
From the Tools menu, click the Options item. Click General under the Windows Forms Designer item and ensure that the AutoToolboxPopulate option is set to True.
The next step is to create an instance of the custom component on the form. Because the Toolbox automatically accounts for the new component, this is as easy as creating any other component or control.
Open the project's form in the Forms Designer.
In the Toolbox, click the new tab called ToolboxExample Components.
Once you click the tab, you will see DemoComponent.
Opomba
For performance reasons, components in the auto-populated area of the Toolbox do not display custom bitmaps, and the ToolboxBitmapAttribute is not supported. To display an icon for a custom component in the Toolbox, use the Choose Toolbox Items dialog box to load your component.
Drag your component onto your form.
An instance of the component is created and added to the Component Tray.
The Toolbox takes account of the components in each loaded project, and when a project is unloaded, it removes references to the project's components.
Unload the project from the solution.
For more information about unloading projects, see How to: Unload and Reload Projects. If you are prompted to save, choose Yes.
Add a new Windows Application project to the solution. Open the form in the Designer.
The ToolboxExample Components tab from the previous project is now gone.
Reload the ToolboxExample
project.
The ToolboxExample Components tab now reappears.
This walkthrough demonstrates that the Toolbox takes account of a project's components, but the Toolbox is also takes account of controls. Experiment with your own custom controls by adding and removing control projects from your solution.
Povratne informacije o izdelku .NET Desktop feedback
.NET Desktop feedback je odprtokodni projekt. Izberite povezavo za pošiljanje povratnih informacij:
Dogodek
17. mar., 21h - 21. mar., 10h
Pridružite se nizu srečanj in ustvarite prilagodljive rešitve za AI na podlagi primerov uporabe v resničnem svetu s kolegi razvijalci in strokovnjaki.
Prijavite se zdajUsposabljanje
Modul
Build reusable components with Blazor - Training
Learn how to use Razor class libraries to package and deploy components with Blazor.
Dokumentacija
Troubleshooting Control and Component Authoring - Windows Forms .NET Framework
Learn about common problems that arise when developing components and controls, with potential solutions for those problems.
Position Controls - Windows Forms .NET Framework
Learn how to use the Windows Forms Designer in Visual Studio or the Location property to position your controls.
Toolbox window - Visual Studio (Windows)
Learn about the Toolbox window and how it displays controls that you can add to Visual Studio projects.