Skip to content

Commit a6d77fa

Browse files
mjrousosRon Petrusha
authored andcommitted
WinForms DataGridView sample (#456)
* Initial copy from https://code.msdn.microsoft.com/windowsdesktop/CSWinFormDataGridView-29783221 * Upgrade sln * Migrate csproj and remove a couple unused files * Work around dotnet/corefx#26745 * Replace description.html with README.md * Remove MSLPL license since this will now be covered by the MIT license in the repository root * Add screenshots to README * Remove license references in source comments since the sample now uses the repo's MIT license * Reformat old ReadMe.txt files into markdown and cleanup links * Small style improvements based on PR feedback
1 parent dd622d9 commit a6d77fa

35 files changed

+3677
-2
lines changed

windowsforms/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ If you're new to .NET Core, here are a few resources to help you understand the
1414
| ----------- | ----------- |
1515
| [Hello World - shared source](helloworld-sharedsource) | This sample shows you how to share source between a .NET Framework WinForms application and a .NET Core WinForms application. Use this to get the full .NET Framework tooling experience while still building for .NET Core. |
1616
| [Matching Game](matching-game) | This sample demonstrates simple event handling and timers in a .NET Core 3 WinForms application |
17+
| [DataGridView Sample](datagridview) | This sample demonstrates DataGridView usage in .NET Core 3 |
1718

1819
## Getting Started
1920

@@ -50,7 +51,7 @@ Ideally you should migrate all projects in your solution to target .NET Core 3.0
5051
1. Start from a working Solution. You must be able to open the solution in Visual Studio and double check that you can build and run without any issues.
5152
2. If your solution also has server-side projects, such as ASP.NET, we recommend splitting your solution into different server and client solutions. For this effort, work with the client solution only.
5253
3. Add a new .NET Core 3.0 Windows Forms project to the solution. Adding this project to a sibling folder to your existing 'head' project will make it easier to port references later (using relative paths to other projects or assemblies in the solution)
53-
4. If your 'head' project uses NuGet packages, you must add the same NuGet packages to the new project. The new SDK-Style projects only support the PackageReference format for adding NuGet package references. If your existing project uses `packages.config`, you must migrate to the new format. You can use the Migrator Tool described [here](https://docs.microsoft.com/en-us/nuget/reference/migrate-packages-config-to-package-reference) to automate this process.
54+
4. If your 'head' project uses NuGet packages, you must add the same NuGet packages to the new project. The new SDK-Style projects only support the PackageReference format for adding NuGet package references. If your existing project uses `packages.config`, you must migrate to the new format. You can use the Migrator Tool described [here](https://docs.microsoft.com/nuget/reference/migrate-packages-config-to-package-reference) to automate this process.
5455
6. Copy the `PackageReference` elements generated in the previous step from the original project into the new project's .csproj file.
5556
7. Copy the `ProjectReference` elements from the original project. Note: The new project format does not use the `Name` and `ProjectGuid` elements, so you can safely delete those.
5657
8. At this point it's a good idea to try and restore/build to make sure all dependencies are properly configured.
@@ -68,7 +69,7 @@ Most existing projects include an `AssemblyInfo.cs` file in the Properties folde
6869
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
6970
```
7071
#### Include the Windows.Compatibility Pack
71-
Not every framework assembly is available in the .NET Core base class library. Windows applications like WinForms and WPF could have dependencies that are not available in .NET Core or .NET Standard. Adding a reference to the [Windows Compatibilty Pack](https://docs.microsoft.com/en-us/dotnet/core/porting/windows-compat-pack) will help reduce missing assembly dependencies as it includes several types that might be needed by your application.
72+
Not every framework assembly is available in the .NET Core base class library. Windows applications like WinForms and WPF could have dependencies that are not available in .NET Core or .NET Standard. Adding a reference to the [Windows Compatibilty Pack](https://docs.microsoft.com/dotnet/core/porting/windows-compat-pack) will help reduce missing assembly dependencies as it includes several types that might be needed by your application.
7273

7374
```cmd
7475
dotnet add package Microsoft.Windows.Compatibility
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.28218.60
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSWinFormDataGridView", "CSWinFormDataGridView\CSWinFormDataGridView.csproj", "{9FED9E6C-4128-4355-9487-74F1B7107CF2}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{9FED9E6C-4128-4355-9487-74F1B7107CF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{9FED9E6C-4128-4355-9487-74F1B7107CF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{9FED9E6C-4128-4355-9487-74F1B7107CF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{9FED9E6C-4128-4355-9487-74F1B7107CF2}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>netcoreapp3.0</TargetFramework>
6+
<RootNamespace>CSWinFormDataGridView</RootNamespace>
7+
<AssemblyName>CSWinFormDataGridView</AssemblyName>
8+
9+
<!-- Don't automatically generate assembly info attributes
10+
found in AssemblyInfo.cs. This property is useful for
11+
applications ported from NetFx, which may have used
12+
AssemblyInfo.cs -->
13+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
14+
</PropertyGroup>
15+
16+
<ItemGroup>
17+
<FrameworkReference Include="Microsoft.DesktopUI" />
18+
<PackageReference Include="System.Data.SqlClient" Version="4.5.1" />
19+
</ItemGroup>
20+
21+
<!-- By default, all .cs and .resx files in the current
22+
directory or descendant directories will be included.
23+
Optionally, they can be updated as demonstrated here
24+
so that dependent files will appear as expected in
25+
Visual Studio's solution explorer. -->
26+
<ItemGroup>
27+
<Compile Update="CustomDataGridViewColumn\MainForm.Designer.cs">
28+
<DependentUpon>MainForm.cs</DependentUpon>
29+
</Compile>
30+
<Compile Update="DataGridViewPaging\MainForm.Designer.cs">
31+
<DependentUpon>MainForm.cs</DependentUpon>
32+
</Compile>
33+
<Compile Update="EditingControlHosting\MainForm.Designer.cs">
34+
<DependentUpon>MainForm.cs</DependentUpon>
35+
</Compile>
36+
<Compile Update="JustInTimeDataLoading\MainForm.Designer.cs">
37+
<DependentUpon>MainForm.cs</DependentUpon>
38+
</Compile>
39+
<Compile Update="MultipleLayeredColumnHeader\MainForm.Designer.cs">
40+
<DependentUpon>MainForm.cs</DependentUpon>
41+
</Compile>
42+
<EmbeddedResource Update="CustomDataGridViewColumn\MainForm.resx">
43+
<DependentUpon>MainForm.cs</DependentUpon>
44+
</EmbeddedResource>
45+
<EmbeddedResource Update="DataGridViewPaging\MainForm.resx">
46+
<DependentUpon>MainForm.cs</DependentUpon>
47+
</EmbeddedResource>
48+
<EmbeddedResource Update="EditingControlHosting\MainForm.resx">
49+
<DependentUpon>MainForm.cs</DependentUpon>
50+
</EmbeddedResource>
51+
<EmbeddedResource Update="JustInTimeDataLoading\MainForm.resx">
52+
<DependentUpon>MainForm.cs</DependentUpon>
53+
</EmbeddedResource>
54+
<EmbeddedResource Update="MultipleLayeredColumnHeader\MainForm.resx">
55+
<DependentUpon>MainForm.cs</DependentUpon>
56+
</EmbeddedResource>
57+
<Compile Update="Properties\Resources.Designer.cs">
58+
<DependentUpon>Resources.resx</DependentUpon>
59+
</Compile>
60+
</ItemGroup>
61+
62+
<ItemGroup>
63+
<Content Include="CustomDataGridViewColumn\ReadMe.txt" />
64+
<Content Include="DataGridViewPaging\ReadMe.txt" />
65+
<Content Include="EditingControlHosting\ReadMe.txt" />
66+
<Content Include="JustInTimeDataLoading\ReadMe.txt" />
67+
<Content Include="MultipleLayeredColumnHeader\ReadMe.txt" />
68+
</ItemGroup>
69+
70+
</Project>

windowsforms/datagridview/CSWinFormDataGridView/CustomDataGridViewColumn/MainForm.Designer.cs

Lines changed: 87 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)