VS2017 hangs when adding a user control to a form - winforms

I have a user control modified from this one:
https://github.com/navhaxs/media-control-deskband
I registered this user control using the tools in it and I added a new WinForms project to visualize the control. First time I did it it worked ok, but when I changed it the changes are not reflected in the winform (it still using the original one... although I recompiled it) and when I deleted and re-added it to the form it hangs VS2013... any ideas?
Edit:
As Hass Passant comment suggested I checked devenv.exe in Task Manager. The CPU usage is just around the 1%

I experienced a similar problem. Decision:
Take out the Control that you use as DeskBand, into a separate UserControl. Do not use any Com registrations on it and do not inherit any interfaces and classes except UserControl.
Paste the control from the first step into your DeskBand control and specify property Dock as Fill.
Paste the control from the first step into your WinForms project.

Related

Visual Studio toolbox custom controls only visible once

I know there are a lot of problems like that and you all might think this is a duplicate but NO... this problem is different.
When I add a custom user control to a project and rebuild it, the control is added to the toolbox. If I try to add another one it does not show up in the toolbox. If I close visual studio and reopen it the first control also was removed from the toolbox and will never appear again. From now on the project is broken and no control added, remove + readded will ever show up in the toolbox. So I create a new project and it starts from the beginning.
Before this tip appears I'll say it: Automatically Populate Toolbox is True. Nothing helps against this problem. Build Project/Solution, Rebuild, Clean+Rebuild, Restart of VS, Restart of Computer, Unload and reload the project, set toolbox back to default. Nothing works.
Any ideas??
You have to remember that the designer call your code constructor and some other methods at design time.
If you build the code and the control does not appears and it has not been hidden by an attribute, then probably the code you wrote is not compatible with the designer. For example, the control might throw an exception in design mode because of incorrect code.
The attribute is [ToolboxItem(false)]. If you have a base class that hide it, it will also be hidden in derived class if not specified otherwise.
You will have the same problem if that control is used in another component. You won't see it if it does not compile and run correctly.
The trick to debug that kind of problem, is to attach a debugger from a second instance of Visual Studio to find where in your code you throw an exception.
If the control does not work at run-time, better to fix that first as if it also fix design problem, it is simpler to debug that way.
Otherwise, you have to ensure that your project dependencies are correct. The toolbox will only shows component from DLLs that are referenced by the current project (or from itself I think).

Controls moving in vs2008 design mode on build

I have a C#.NET winforms project, and some controls are moving in design view whenever I build the project. Its only some of the controls (a panel with a label and datagridview in it, a button, a link button and a label) are all moving up on each build.
Has anyone seen this before or know how to fix it?
I think it is because of the AutoScaleDimensions. My guess is that your form was originally created on another machine.
Per MSDN.
"The AutoScaleDimensions property represents the DPI or font setting
of the screen that the control was scaled to or designed for.
Specifically, at design time this property will be set by the Windows
Forms designer to the value your monitor is currently using. Then,
when the form loads at run time, if the CurrentAutoScaleDimensions
property is different from the AutoScaleDimensions, the
PerformAutoScale method will be called to perform scaling of the
control and all of its children. Afterwards, AutoScaleDimensions will
be updated to reflect the new scaling size."
My guess is that for odd some reason when you build you project property (maybe some others) gets adjusted, but not on design time.
I think about few possible reasons:
You work on multiple monitors and/or there is some odd stuff with your adapter.
There is some problem with auto-generated designer file. Maybe it
edited manually somehow.
To fix I propose to do something I would do:
Recreate form from scratch if possible, by copy-pasting bits
one-by-one.
If not take some merging tool and insert fresh form
properties.
Also here is another interesting question on AutoScaleDimentions.

DevExpress PivotGrid (Silverlight) : Popup Menus don't popup

We are using DevExpress Silverlight PivotGrid (11.2.7). The problem is that none of the popups work as one would expect.
Here is the xaml code (note that all of these properties are True by default and don't need to be set)
<dxpg:PivotGridControl
x:Name="pivotGrid"
... data bindings ...
IsFieldValuePopupMenuEnabled="True"
IsHeaderMenuEnabled="True"
IsHeaderAreaMenuEnabled="True"
/>
Once the host control for the grid is shown and the data is loaded right-clicking on any of the relevant areas doesn't bring either of the popups (there are 3).
Strangely (or not so strangely) in the sample SL project provided by devex everything works as it should.
The one (significant) difference between the sample app and our project is that we are using MEF and relevant .xaps are loaded dynamically based on which user logged in and some other stuff.
We have tried a lot stuff to figure out what is wrong but haven't managed to find anything even remotely relevant. Here is what we have tried :
Adding the pivotgrid to the host tabpage in codebehind after imports have been satisfied;
Setting / resetting properties mentioned above after imports from codebehind;
Adding the control to the startup page of the project before the MEF madness kicks in;
We also tried to popup the menus manually by inheriting from the pivotgrid control, but that has not yielded much;
Enabled RedrawRegions to make sure the popup is not popping 'under'. It's not;
Any pointers or ideas would be greatly appreciated.
Regards,
Alex
It appears that this was some bug in the version we were using at the time.
After updating to 12.1 everything works like it should without any tinkering from our side.
Looks like devex guys have bugs too...who knew right :)

VS2010 Winforms Usercontrol changes not showing in parent form

I've created a series of usercontrols. Dragged one of the controls to the main form. It shows OK. Went back and made a change to the design of the user control. Rebuilt project. Cleaned project. manually removed all project binaries including the obj folder. Change still doesn't show on the usercontrol hosted on the main form. Dragging a new instance of the control from the tool box only shows the old version of the control.
Completely removed the controls from the toolbox and adding them again fixed the problem, but surely I don't have to do this everytime I make a change? All user controls are in the same assembly as the main form. Tool>Options>Windows Forms Designer>Auto toolbox Populate is set to true. Any ideas most appreciated. Thx
Do not add the control to the toolbox yourself. This puts a copy of the assembly in a private directory. Yes, this copy does not get updated automatically, you get the old control.
Rely on the "Auto toolbox populate" setting. It automatically adds any controls you have in your loaded project(s) to the toolbox. The added controls are at the top of the toolbox.
I agree with answer 1 that that is what is supposed to happen, and often does. But it doesn't always work and will work partially sometimes.
For example my current Solution.
Project 1 namespace ToolsTester - This is just a temporary form to test the view tools in the 2nd project.
Project 2 namespace UltimateFileFinder - This has three views.
The first 2 views (user controls) UltFilesView and UltSlideShow appeared as usual on the toolbar so I could drag them onto ToolsTester to try them out.
Then I added another user control UltPanel, this will not go onto the toolbox. Though it compiles without errors.
I have come across this problem a few times, sometimes removing and reasserting the reference fixes it. Other times I would have to remove the test project and create a new one.
I tested Visual Studio (full version) before release and this was one of the areas I reported back, so the problem was known pre-release.
This project I am on now I know that I will need to remove the test project and create a new one, in this case the tester is only a few simple caller and event responses, that is not always the case, there are times when the tester project can be quite complex because it is mimicing the target that the tools will be part of.

windows application user control in wpf

I have created a user control in windows application and used it in wpf.
The user control is in a seperate project and solution than that of wpf.
I have exposed some properties in the user control and tried to use it in a wpf form.
I have used it in the WindowsFormsHost element and also added WindowsFormsIntegration reference.
I am facing the following problems:
I am able to see the user control in the toolbox but it is disabled.
I am able to design the user control in xaml and give values to properties. I am also getting the properties in intellisense but the same is not getting reflected/applied during design as well as run time.
I am not able to see the control in the properties window even after selecting it. I am just able to see WindowsFormsHost in the property window.
I am not able to find any sample project or explanation of this in code project. If there is any then please do let me know.
Also I am able to use this user control in a windows application very easily and it is working fine. Am i missing anything for wpf?
I can give the source code if required but i dont think it will be of much help as i have not done anything fancy.
Is the control project compiled or just added in the solution?
Is the control project compiled as Debug or Release?
What language is the control compiled in?
"Walkthrough: Hosting a Windows Forms Control in WPF"
Possible help:
http://social.msdn.microsoft.com/forums/en-US/wpf/thread/2fd0d9dd-eaa9-494d-8ec4-d896c33732d6

Resources