Skip to content

Windows Forms Data Visualization for .Net 5

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.TXT
Notifications You must be signed in to change notification settings

PaulaScholz/WindowsFormsDataVisualization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

winforms-datavisualization .Net 5

This is a porting to .Net5 of dotnet/winforms-datavisualization project and the sample solution as well, by Angelo Cresta, who did the original port and posted it in an article on Code Project.

My slight value add was to remove obsolete code security statements and null checks, and to suppress MSBuild warning number MSB3042 regarding a conditional compilation directive in the tool-created ChartWin SR.cs code file, inside the ChartWin.csproj file, like this:

 <!-- Suppress MSBuild resource conditional compilation warning in tool-generated ChartWin SR.cs code. -->
 <PropertyGroup>
   <NoWarn>$(NoWarn);MSB3042</NoWarn>
 </PropertyGroup>

The resulting solution should now build with no warnings under .Net 5.

Data Visualization

This repository contains partial source code of the System.Windows.Forms.DataVisualization namespace that provides charting for WinForms. Microsoft ported and open sourced those components to enable charting features for WinForms applications that are developed on .NET Core 3.

I've made the porting to .Net 5:

  • updating references
  • updating project files
  • moving deprecated controls like ContextMenu, MenuItems to new ones (ContextMenuStrip, ToolStripMenuItems) and relative methods
  • ...

Application Running .Net 5:

ApplicationRunning

Points of Interest

Removed controls starting with .Net Core 3.1

Starting with .NET Core 3.1, various Windows Forms controls are no longer available. Replacement controls that have better design and support were introduced in .NET Framework 2.0. The deprecated controls were previously removed from designer toolboxes but were still available to be used (source).

The following types are no longer available:

ContextMenu DataGrid DataGrid.HitTestType DataGridBoolColumn DataGridCell DataGridColumnStyle DataGridLineStyle DataGridParentRowsLabelStyle DataGridPreferredColumnWidthTypeConverter DataGridTableStyle DataGridTextBox DataGridTextBoxColumn GridColumnStylesCollection GridTablesFactory GridTableStylesCollection IDataGridEditingService IMenuEditorService MainMenu Menu Menu.MenuItemCollection MenuItem ToolBar ToolBarAppearance ToolBarButton ToolBar.ToolBarButtonCollection ToolBarButtonClickEventArgs ToolBarButtonStyle ToolBarTextAlign

RECOMMENDED ACTION

Removed control (API) Recommended replacement
ContextMenu ContextMenuStrip
MenuItem ToolStripMenuItem

That's what has been performed on the project.

References

The original port to .Net Core 3.0 used very old and still in Beta/Preview references:

RefPackages

and moving away from them was a bit tricky, now they're all actualized:

RefPack2

In a future release, maybe the use of System.Data.SqlClient should be avoided ...

CSProj

The CSProj files were also modified according to the new target / Platform (Windows):

Original (Relavant Portion):

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <AssemblyName>System.Windows.Forms.DataVisualization</AssemblyName>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <CLSCompliant>false</CLSCompliant>
    <NoWarn>$(NoWarn);618</NoWarn>
    <DefineConstants>$(DefineConstants);WINFORMS_CONTROL</DefineConstants>
    <!-- <Win32Manifest>Resources\System\Windows\Forms\XPThemes.manifest</Win32Manifest> -->
  </PropertyGroup>

Ported Version (Relavant Portion):

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
  <PropertyGroup>
    <TargetFramework>net5.0-windows</TargetFramework>
    <AssemblyName>System.Windows.Forms.DataVisualization</AssemblyName>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <CLSCompliant>false</CLSCompliant>
    <NoWarn>$(NoWarn);618</NoWarn>
    <UseWindowsForms>true</UseWindowsForms>
    <ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
    <DefineConstants>$(DefineConstants);WINFORMS_CONTROL</DefineConstants>
  </PropertyGroup>

You have to pay attention to this directive<UseWindowsForms>true</UseWindowsForms>:

The UseWindowsForms property controls whether or not your application is built to target Windows Forms.

This property alters the MSBuild pipeline to correctly process a Windows Forms project and related files. The default value is false. Set the UseWindowsForms property to true to enable Windows Forms support. You can only target the Windows platform when this setting is enabled (source).

Getting started with Chart Controls

The best way to learn about Chart Controls is by looking at the sample solution where via interactive experience with the app you can learn about every chart type and every major feature. While modifying the control parameters and instantly seeing how that affects the look of the control, you can also get the generated C# or Visual Basic code to use in your apps.

Chart Controls

With the sample project you can see every property and parameters in action:

Sample1

and then copy the relavant portion of the code (C# or VB.Net):

Sample2

History

8th April: Initial Porting to .Net 5

Hope this helps!

About

Windows Forms Data Visualization for .Net 5

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.TXT

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages