0

I migrated my winforms .Net Framework application to .net Core 3.1, but some controls are missing in the toolbox like DataGridView.

Is there a way to activate those missing controls as Microsoft intends to support them later.

Emad Mohamed
  • 97
  • 2
  • 10
  • 1
    Is this a question? Or an answer posted mistakenly as a question? If it's a workaround for a problem, you may want to ask a question explaining the problem. Then post the answer for your own question. – Reza Aghaei Feb 03 '20 at 10:20
  • Sorry for being late to add another notification. – Emad Mohamed Feb 03 '20 at 10:27
  • In particular, you should check [this question](https://stackoverflow.com/questions/59952919/does-winforms-net-core-3-support-all-net-framework-controls/59954655#59954655) to see if the applicable solution isn't good enough already. My question to you would be what your modifications does instead, will it generate .NET compatible core or might the forced designer support generate issues? – Lasse V. Karlsen Feb 03 '20 at 10:33
  • I'm voting to close this post as off-topic because it's not a question. – Reza Aghaei Feb 03 '20 at 10:34
  • no need to vote, I will delete it .. just wanted to share information without paying attention to routine procedures. – Emad Mohamed Feb 03 '20 at 10:37
  • Don't get offended, It's really appreciated that you want to share :) but just take a [tour] and take a look at [help](https://stackoverflow.com/help) to know more about site's format and regulations like off-topic, on-topic, how to ask , ... – Reza Aghaei Feb 03 '20 at 10:37

1 Answers1

4

We know that Microsoft Visual Studio Preview 2 with .Net Core 3.1 is missing some Winforms controls like DataGridView, and others. Microsoft is planning to support the missing controls soon.

This simple trick can easily activate all the missing controls to start your Winforms .Net Core 3.1

Before you do these steps, just know that is only confirmed for testing, and not for production yet. one It is confirmed for final production application, I will update the post.

this solution is confirmed for me with .Net Framework 4.8 and .net Core 3.1.

with some steps as following: 1- Create your winofrms .Net Core project. 2- Press on project_name.csproj and change this:

    <TargetFrameworks>netcoreapp3.1</TargetFrameworks>

to this new one:

    <TargetFrameworks>net48;netcoreapp3.1</TargetFrameworks>

3- Then open Program.cs and comment this

Application.SetHighDpiMode(HighDpiMode.SystemAware);

To be like this:

//Application.SetHighDpiMode(HighDpiMode.SystemAware);

this solution will add all the controls. just close the solution and reopen.

4- After you finish your application, just change everything to default again like this:

Press on project_name.csproj and change this:

    <TargetFrameworks>netcoreapp3.1</TargetFrameworks>

For the program.cs uncomment, even after I rolled back to default, the application give an error for this line, so I keep it commented

Thanks goes for Kirsan

https://devblogs.microsoft.com/dotnet/updates-to-net-core-windows-forms-designer-in-visual-studio-16-5-preview-1/#comment-4562

This is not a question, It is a helping post. So please no need to provide answers. Your comments are highly appreciated.

Emad Mohamed
  • 97
  • 2
  • 10
  • *It is a helping post* → stackoverflow doesn't works like this. For a *helpful post* you need to ask a question focusing on a specific problem, then answer the question using your *helpful post*. – Reza Aghaei Feb 03 '20 at 10:30
  • Please use the edit link on your question to add additional information. The Post Answer button should be used only for complete answers to the question. – GMB Feb 03 '20 at 12:38
  • Adding `net48` to `TargetFrameworks` was enough. But removing `net48` also removed the button from the toolbox. Readers, notice the trailing _S_ in `TargetFrameworks`. – bvj Apr 27 '20 at 08:49
  • this does not work for me, it wont open the designer, it will show callstack errors – Jaroslav Daníček Jul 23 '20 at 12:00
  • In VS 2019 Ver 16.6.5, I was able to recover the missing controls Except DataGridView by deleting the files mentioned in: developercommunity.visualstudio.com/comments/1045118/view.html – Jawad Al Shaikh Aug 04 '20 at 13:25