Open paul1956 opened 2 years ago
Most UserControl scenarios are working, at least in C#. @KlausLoeffelmann do you have issues with this in VB.NET? Can you take a look?
Hello, After creating a usercontrol in VB with .net6 for a WinForm project with version 17.2.6 of visual studio, it is still impossible to add this usercontrol to the toolbox. This usercontrol works fine in its creation project. Here is the error message in French:
Translated message : D:\Documents\Visual Studio 2022\Projects\Component_Net6\Gauge.dll targets a platform whose elements cannot be enumerated dynamically.
There is no such problem with the 4.8 framework.
Currently I just updated visual studio to version 17.3.1. Now, with this version, when you ask to choose elements to add in a toolbox tab from the context menu, you no longer have the display of the element selection window. This situation is the same for .net6 and framework 4.8 projects.
Yes, it doesn't work in VB. @dreddy-work: Do you have any ideas why this might fail?
Choose Toolbox Items
is not enable for .NET yet. VB user controls not showing up in the toolbox is being investigated under issue https://github.com/microsoft/winforms-designer/issues/4558 (internal repo)
Regarding User controls being removed when edited in the designer is a different issue that need to be investigated separately.
@dreddy-work: No, this is not what I mean.
If you have a Custom Control (public/internal Class deriving from System.Windows.Forms.Control
) in a VB Project, it is supposed to be populated in the Toolbox. That doesn't work. It works for C#, not for Visual Basic.
If you reference your VB project to a C# class library containing a Custom Control, that control gets populated.
If you reference your VB project to a VB class library containing a Custom Control, that control also does not get populated.
So, this is broken for VB, and this needs to be fixed. I think this is at least Prio 1. And I would suggest also Servicing this for 17.3. @merriemcgaw?
Klaus
@Olina-Zhang: Could you create an issue in the Designer for this (if we don't have one yet), link it to here, and assign Devender and me to it? Thanks!
Repo is:
Public Class CustomControl
Inherits Control
End Class
* Build Project.
* Open Form1.VB
* Check, if control gets populated in toolbox.
In addition:
We will also need to check, if NuGets created based on VB WinForms Class Libraries containing Custom Control get automatically populated to the ToolBox.
Linked PR is fixing the issue for showing Toolbox items form VB projects in Toolbox explorer. Later part of the issue where editing Form designer removing the user control need to be investigated further if it still repo after this.
Linked fix should fix populating Toolbox items for VB projects and as well as Nuget packages built from VB projects.
Currently I just updated visual studio to version 17.3.1. Now, with this version, when you ask to choose elements to add in a toolbox tab from the context menu, you no longer have the display of the element selection window. This situation is the same for .net6 and framework 4.8 projects.
@Perpete This issue has been fixed in another team, and you can track it at here: https://developercommunity.visualstudio.com/t/Visual-Studio-2022-173-Chargement-de-/10120433
@KlausLoeffelmann, will be taking a look further if there is anything else that need to be addressed here.
I am also seeing lots of churn (via GitHub) when anything in the file change (unrelated to DataGridView) a should I open a separate issue?
These changes happen constantly they don't break anything they just renumber CellStyles The next change restores the original values
@paul1956 yes, it's better to track unrelated issues separately.
In this specific case, I think the .NET Framework designer behaves the same way, and, if this is so, this issue won't have a high priority for the team. I agree this is affecting the developer experience (and it's bitten me too few times in the past too), but this is not technically wrong (i.e., the code is not broken).
@RussKie At least its documented now. Feel free to handle as you see fit. When I used Framework, I didn't have Git.
I am also seeing lots of churn (via GitHub) when anything in the file change (unrelated to DataGridView) a should I open a separate issue?
I am wondering, if this particular one is caused by the custom CodeDomSerializer of the DataGridView.
@KlausLoeffelmann I don't know but I am seeing it in other places but more subtle where spaces are added and removed around (). I don't have a specific example right now but next time I get one I will open a separate issue. I will change title of #7653 to include DataGridView and update the issue.
Back to the original issue, @paul1956, @merriemcgaw, @Tanya-Solyanik, @dreddy-work, @RussKie:
There does not seem to be a way to add a user control to Toolbox and adding the control manually to Designer File manually works as long as you don't open the designer where parts of it will be deleted. The Symbol will be preserved but most of the initializations will be deleted.
You can add a user control (indirectly) by this:
internal
(friend
in VB) scope in the same project. On build, it will automatically get populated to the toolbox, as long as it's not prevented by this Tools/Option setting:The other way, that there are toolbox items in the toolbox, and adding those items to a Form of a project automatically adds a reference to it, is currently not supported for .NET. But I am asking, why that is important? If you wanted to target specific scenarios with a specific set of controls to solve that scenario, as a library author you could provide project templates which would pull in the respective NuGet/Project references, and then the toolbox would get (pre-)populated with that exact set of controls/toolbox items that you need. This way, you would also not clutter the toolbox with controls you'd only need once in a while.
But there might be scenarios which I am missing. So, what exactly are those scenarios, and why can they only be addressed with toolbox elements already in the toolbox?
BTW: We just fixed a bug which prevented populating the toolbox in all these scenarios in VB projects. That bug should be fixed both in 17.3 and 17.4 with the upcoming (service) releases.
Broken again in 17.4.2. User components from dependent assemblies are not displayed in the toolbox and disappear if they already on the form.
Haven't noticed, and I am doing custom controls in vacation side project the whole time. Is this an isolated thing? Visual Basic only, or also C#? Does it repo with a minimal project? Does it work with the same project?
(I won't be able to follow up before January due to holiday vacation.)
Hello, From a new Winform project in VB, it is still impossible to add a created control (Usercontrol) to the toolbox for version 17.4.2 of visual studio with net6 or net7. Always the same message. "D:\Documents\Visual Studio 2022\Projects\Component_Net6\Gauge.dll targets a platform whose elements cannot be enumerated dynamically." See my comment of August 18.
Just to be clear as we are talking different issues here and also to support what @KlausLoeffelmann said above.
@Perpete / @2mik , if you have any other issues that are not covered in the above list, Please share the scenario with a simple repro application.
Hope the issue will be fixed in 17.4.3 as this issue promises. If no, I will upload the detailed example. Is Visual Studio supported with GitHub or we have to use inconvenient developercommunity.visualstudio.com ?
@2mik we can continue the discussion here and the team will update VS DeveloperCommunity ticket as well when the fix is released. The benefit of Developer Community is that we are able to exchange more private information than we are on GitHub if that is important to you. Otherwise, Developer Community also gives us the ability to collect more logs instead of you having to upload them here. Whichever your preference is, please continue to use it. 😄
as a library author you could provide project templates which would pull in the respective NuGet/Project references, and then the toolbox would get (pre-)populated with that exact set of controls/toolbox items that you need. This way, you would also not clutter the toolbox with controls you'd only need once in a while.
But there might be scenarios which I am missing. So, what exactly are those scenarios, and why can they only be addressed with toolbox elements already in the toolbox?
Excuse me, but as the (amateur) author of a controls library that I am: are you really judging people for the reasons that can have for always wanting to have a set of custom controls available by default, such as productivity, versatility, and time saving?.
Imagine that the Windows Forms designer is empty by default, and then the end-user always needs to find, load and select the controls and components that he wants to be there, every time for every single project that is created.
It would simply be absurd and unproductive. So in the same way, a developer does not need to justify or give you a good reason for always wanting to have his own custom controls available in the toolbox for all projects, because the reasons are in essence the same reasons as why the Microsoft team decided to do so with a set of controls.
So I can have a project template with the assembly references as you said, yes, but I also want the possibility to pick a custom user control of mine (or of whoever) from the controls toolbox on any project, because I want to use it and that's all, so I want to have it available there, always.
How can you even suggest that's a problem that should be ignored to downplay its importance?.
I'm not sure whether my issue is related to this GitHub issue, but this GitHub issue was opened in Aug 17, 2022, and still not fixed in 2024...?
In any case, my issue was published on StackOverflow website and describes the headaches I'm having to figure out how to add a simple user control (contained in a DLL file) to the Windows Forms designer on a NET Core solution:
Please, check it out.
Tried with C# and VB.NET projects, it just does not work.
Environment
Version 17.4.0 Preview 1.0
.NET version
6
Did this work in a previous version of Visual Studio and/or previous .NET release?
Yes under Framework
Issue description
There does not seem to be a way to add a user control to Toolbox and adding the control manually to Designer File manually works as long as you don't open the designer where parts of it will be deleted. The Symbol will be preserved but most of the initializations will be deleted.
Has an example that works as long as you don't open Form1 in designer. Plus no way to get User Control in ToolBox
https://github.com/paul1956/ToolStripComboBoxExTest
Steps to reproduce
https://github.com/paul1956/ToolStripComboBoxExTest. Run the program and see the User Control working. Then open Form1 in designer and make any change and the User Control will be deleted.
Diagnostics