NET from version .NET Core 3.1 up to .NET 7 has plenty of advantages over .NETFramework: it provides performance improvements in almost every area, and thoseimprovements were an ongoing effort over each .NET version. Thelatest improvements in .NET6 and.NET7 arereally worth checking out.
Migrating your Windows Forms (WinForms) Visual Basic Apps to .NET 6/7+ alsoallows to adopt modern technologies which are not (or are no longer) supported in .NETFramework. EFCore is one example: it isa modern Entity Framework data access technology that enables .NET developers towork with database backends using .NET objects. Although it is not nativelysupported for VB by Microsoft, it is designed in a way that it is easy for thecommunity to build up on it and provide code generation support for additionallanguages like Visual Basic. Inthat context there are also changes and improvements in the new WinFormsOut-of-Process Designer for .NET, especially around Object DataSources.For the WinForms .NET runtime, there are a series of improvements in differentareas which have been introduced with the latest releases of .NET:
.NET 5 introduced the TaskDialogcontrol,a series of ListView controlenhancements,FileDialog classenhancementsand a noticeable performance and memory usage improvement aroundGDI+..NET (in .NET Core 3.1) also changed the default font for WinForms Formsand UserControls to Segoe UI, 9pt to let the typical WinForms UI have a moremodern look and feel.
Windows Visual Styles is to determine if the application will use the mostcurrent version for the Control Library comctl.dll to provide controlrendering with modern visual styling. This setting translates to the valueEnableVisualStyles of type Boolean inside of Application.myapp.
Single-instance application is to determine if the application will preventusers from running multiple instances of the application. This setting isswitched off by default, which allows multiple instances of the application tobe run concurrently. This setting translates to the value SingleInstance oftype Boolean.
Adding to the list of settings automatically generates respective code, whichcan be easily access over the My object in the Visual Basic ApplicationFramework atruntime.This settings translates to the value SaveMySettingsOnExit of typeBoolean.
High DPI mode is to identify the application-wide HighDpiMode for theapplication. Note that this setting can be programmatically overridden throughthe HighDpiModepropertyof the ApplyApplicationDefaultsEventArgs of the ApplyApplicationDefaultsapplication event. Choose from the following setting:
Shutdown mode is to to indicate which condition causes the application toshut down. This setting translates to the value ShutdownMode as an enumvalue of type Integer (Note: Please also refer to the application eventShutDownand the further remarks down below.):
Splash screen represents the name of the form to be used as a splash screenfor the application. Note that the file name does not need to include theextension (.vb). This setting translates to the value SplashScreen of typeString.
The way basic properties and behaviors of a WinForms app are controlled and configured is fundamentally different between C# and Visual Basic. In C#, every appstarts with a static method called main which can usually be found in a filecalled Program.cs, and in that main method all the setting get applied.
You need to make sure first to show all files for that project (see screenshotabove). Then you can open the My Project-folder and show that setting file inthe editor by double-clicking it in the solution explorer. The content of thatfile looks something like this:
Now, the class which is injected by the compiler is also responsible forgenerating everything which the Visual Basic Application Framework provides youvia the My namespace. The My namespace simplifies access to frequently usedinformation about your WinForms app, your system, or simplifies access tofrequently used APIs. Part of the My namespace for an activated ApplicationFramework is the Application property, and its return type is of exactly thattype which is defined by the class generated based on your Application Settingsand then merged with the injected Visual Basic compiler file mentioned earlier.So, if you access My.Application you are basically accessing a single instanceof the My.MyApplication type which the generated code defines.
To wire up the available Application events, you open that ApplicationEvent.vbcode file, and then you select ApplicationEvents from the Object drop-down list,and the application event you want to write up from the events list:
Note: More general information about the Visual Basic Application Model is provided through the Microsoft Learn Docs about this topic. Also note, that, on top of the extensibility of the My namespace, this Application Model also has extensibility points which are also described in great detail by the respective docs.
And, as always: Feedback about the subject matter is really important to us, soplease let us know your thoughts and additional ideas! Please also note that theWinForms .NET and the Visual Basic Application Framework runtime is open source,and you can contribute! If you have general feature ideas, encountered bugs, oreven want to take on existing issues around the WinForms runtime and submit PRs,have a look at the WinForms Github repo.If you have suggestions around the WinForms Designer feel free to file newissues there as well.
That said, please keep in mind that in a world of HighDPI and Per Monitor V2 requirements, pixel-perfect layouts in WinForms are not a good idea to begin with. So, refactoring layouts to use more features like AutoSize and TableLayoutPanel-based Forms/UserControl is really a useful benefit for app users.
I know that pixel perfect layouts nowadays are not a good idea, but in legacy applications ported to .Net 6 with around a thousand controls it will be a lot helpful if the Out-Of-Process Designer can pick the default font.
3a8082e126