Thursday, October 15, 2020

 Controls

 Often, after arranging a set of controls just right, you need that group of controls elsewhere. In that case, you can copy and paste the controls between forms, making sure that all the settings are maintained, or you can encapsulate the controls into a user control for a more robust form of reuse. User controls are containers for other controls and are best created in a Windows Control Library project. To add a Windows Control Library project to an existing solution, you use the Add New Project item from the menu you get when you right-click on your WinForms application's solution in Solution Explorer. You'll also want to make sure that you're creating the new project in the same location as your existing solution, because VS.NET 2002 defaults to placing new projects one folder too far up the hierarchy in most cases.  shows how to add a new project called MyFirstControlLibrary to an existing solution called MySecondApp.

  Adding a New Project to an Existing Solution


 

 After you've created a control library project, you'll be presented with a user control design surface very like that of a form. The only real difference is that there's no border or caption, which will be provided by the form host of your new control. The code generated by the Wizard looks very much like the code generated for a new form except that the base class is UserControl instead of Form

 

 

No comments:

Post a Comment

 Application Settings As some applications get more sophisticated, users expect more from all their applications. For example, some applicat...