Can't select controls on my form - c#

This has started happening recently (not too sure what caused the change unfortunately), but I can no longer select controls on my form. My reading on this has uncovered some possible explanations including:
You're running your program in debug mode
Your form is derived from another class where everything is private
Your controls are "locked".
For (1), no, it's definitely not running and for (2) my form is derived from DevComponents.DotNetBar.RibbonForm. For (3), no, they're not "locked" (I tried locking and then unlocking, in case some state was stuck in the designer, but no dice). The controls are on my form, not the base class form and the instances aren't private (I deliberately made them public just to test this one) and they were working fine before.
So, what can I do? I can select a control, like a ComboBox, from the Properties window drop-down list, change its properties and so on. But when I choose it nothing gets selected in the designer. I can select the form itself (by its border) and resize it in the designer. I can add a new control, like a label, and interact with it fine in the designer, so this is something that's happened to my existing controls.
I'm sure it's either something spectacularly dumb, or Visual Studio 2012 is on the wind-up.
Anybody?
Edit: Zipped the solution up and brought it home. Cleaned and rebuilt and it's working fine in the designer. I guess there's an issue with my install at work, somehow.

The problem can occur when a new version of DevComponents.DotNetBar is installed and the old version is still referenced from a separate library folder.
The app and all DotNetBar referenced dlls should be re-referenced to the latest version.

Well, I kind-of solved the problem, although I don't know what the actual cause was. In my program I'm referencing devcomponents.dotnetbar dll. I removed the reference and then re-added it, rebuilt the program and now everything's working in the designer as it should.

This problem's main reason is because of older versions of components being used in a project and a newer version of the component has been installed on the machine. 9 times out of 10, the project is still pointed to the component in the GAC. Remove the reference to the component and re-add it from the newly installed component's location and all should work fine.

I had the same issue with DotnetBar, resolved it by adding the reference DevComponents.DotNetBar.Design.DLL in the project

Just right-click the form and uncheck Lock Controls.

Resetting the Toolbox (Right click inside Toolbox) and then "reinstalling" the new toolbars did the trick for me. Seems to be a bug in Visual Studio.

I had the same situation but Closing and Re-Opening my project solved the problem

I had the same issue after moving a project to another PC. I didn't install DotNetBar on the new machine and just copied the DevComponents.DotNetBar.dll. I resolved it by also copying DevComponents.DotNetBar.Design.dll (contained in the old machine's DotNetBar installation directory) to the new machine and referencing it in the project.

The general issue is using references that no longer exist. For me, I had several versions of Infragistics controls and uninstalled all but the latest version. At least one of my references pointed to a DLL that didn't exist. Therefore, the seeming removal and re-adding essentially pointed the references to the correct (or present) DLLs.
Also, one of the symptoms of this problem is that the labels for the controls appears in a window below the dialog/form.

To get this working for me I ended up having to add the references to the designer for the different controls: SuperGrid.Design and DotNetBar.Design

I had that problem, and it was caused after I wrongfully played around with my "using" and "namespaces" in a blind attempt to get rid of an error. I saved each .cs file one by one and then closed VS and re-opened it. Presto, the little locks vanished.

I had the same issue, you can ctrl+a to select all, then move the controls to somewhere, doesn't matter where. Now you will be able to select them again seperately.
I got this problem by dragging a tab down so i could see two codes at the same time.

I know this is an old post, but in case it helps someone else, my version of this problem was an inability to select controls on a tab page. Sending the tab page to the back didn't help. But I found I could get the controls highlighted by selecting them in the properties box and then placing the mouse over the control sizing arrows and right clicking, I could then bring the controls forward.

Just Closing the current Soln and Opening again solves this problem,
This might have caused because of some hidden selections in other forms!

For me the issue was only with "Send to Back" and "Bring to Front"
I did Control+A then deselected every other control, then right clicked on the controls i was not able to see before and just clicked "Bring To Front".
For me the issue happened because i removed those controls from Group Box.

Visual Studio 2019, I close the form, and any files currently open that are associated with that form (.cs .rex) and then reopen them. This solved my 'not being able to select a control' problem. I find this problem occurs occasionally, and is a bit of a nuisance, but this simple fix always seems to work for me.

I ran into another variation on this theme. I'd placed Infragistics controls into a lib folder. The project would still compile/run, but for the controls to be selectable in the editor the project must reference the original installed controls. See Cannot select Infragistics controls in WinForms designer for more details.

Related

New controls added to Form are not shown when debugging

I'm facing a problem of adding new controls on a form.
While adding controls on my form, I'm normally able to edit them and work with them in .cs files.
When I'm debugging, all new added controls vanish, as well as implementations (like properties) for old controls, and old controls, which were deleted, are still shown.
I have already deleted bin and obj. Problem still appears.
Searching for help!
Cheers
Edit: I checked other projects which are using windows forms too, and in those everything works fine
Just in case, are you using the "Save All" button to save your progress and then debug it ?
If your program is running without problems in debugger but is showing old things, maybe you havent saved your progress ?
Problem solved!
If you have opened your project, click on top "Create" and then on the task "create new -projectname-".
VS needs some seconds for running through the task but after that all implemented controls and task that has not been shown are going to appear. Furthermore all properties etc.

Winforms designer misbehaving, essentially broken

We have a complicated legacy form built in Winforms that recently has started seriously misbehaving and it gets worse and worse as time goes on. Just opening the form in design view will alter the layout of the form, sometimes in minor ways (a control is resized to be a pixel smaller) and sometimes in major ways (a component is moved to X position -6582). Due to the size of this form and the nature of the generated .Designer.cs referring to the diff is almost usually useless to determine whether the changes that were made to the form were the changes that you actually intended.
Based off a number of suggestions I found in other questions:
visual studio 2005 designer moves controls and resizes Form
Visual Studio keeps resizing my form without me telling it to, help!
Controls moving in vs2008 design mode on build
AutoScaleMode is set to None. I experimented briefly with various monitor resolutions, to no avail. Ultimately we decided to stop relying on anchors and instead use a combination of TableLayoutPanels and Dock properties. And that's when the trouble really started...
After heavily redesigning one of the hairier tabs on this form, when I tried to save Visual Studio spun for 2-3 minutes and reported "Could not load file or assmbly 'MyProject, Verion=X.X.X.X, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified" (as seen here: Visual Studio 2013 Can't save, build, or rebuild solution). This happened whenever the form attempted to save. After following the advice in the accepted answer, I was able to save/build again.
Attempting to run not much later resulted in a very, very long build time and a completely empty form (as seen here: All controls on a form are invisible and https://stackoverflow.com/a/5524183/1015495 ). All calls to Controls.Add had been removed from the designer (I assume this massive change is what resulted in the long build time). I restored the form to a previous version and began recreating my changes. Now, much more insidiously, certain controls have had all of their children removed.
Working within this form is becoming a timesink at best and unfeasible at worst. The solutions that I've found online basically boil down to "recreate the form manually" or "don't use Winforms". Unfortunately neither of these are an option right now. How can we mitigate the problems that we're having with this form in the mid-term future until we can come up with a proper fix?
I am working through an almost identical problem at the moment and mine seems to be a bug in Visual Studio 2013 related to having a "linkLabel" control on a User Control, which is on one of the tabs of a tab control on the main form.
I had other linkLabel controls on the parent form that did not cause any issues. The weird thing is that not ALL of the tabs were messed up, only some of them. I can only conclude that it gets through part of the layout restructuring, hits the user control, and bombs out, failing to finish the layout correctly. I attached a second version of visual studio to try to catch exceptions, and saw various status lines showing up in the debugger, but did not see any exceptions thrown. I am not that familiar with doing that, so it's possible I did that wrong though.
I could revert the code back to after I had added the user controls, but before VisualStudio opened the form in the designer and automatically re-generated the designer code. At this point, opening the form in the designer will always cause exactly the same design failures. As long as I never opened the code in the designer again, everything would work correctly at run time.
If I removed any reference to the custom user controls with link labels, the designer would also open without any trouble. At first I assumed I had an error in my own code so I started commenting things out, but it was still happening even with just the basic elements dragged on. So then I started removing elements and adding them back one at a time to see what broke it. In my case this turned out to be the "linkLabel" control. I am not sure if there are other controls that will do this yet. For now I just plan on re-writing the code to not use a link label on the user control though and see how well that goes.

Can't Move Controls With Mouse on Windows Form Designer

I recently installed Visual Studio 2013 Professional, and found that in the Windows Forms Application project type I'm unable to move any controls on a form in design mode. I tested a few alternatives out and found the following:
Controls can be moved with the keyboard
Controls can be resized by dragging the keypoints on the outline of the control
Controls can be aligned using the commands in the Tools menu
Controls can be moved by setting the Location field manually in the designer property grid
Controls can be docked
Controls cannot be moved with the mouse
Furthermore, as you can see in the image below, the "cross" icon that indicates that the controls are movable is not visible on any controls.
I've tried the following, but have not yet been able to correct the issue:
Created a new project & solution (same issue)
Created a new form (same issue)
Verified that the Locked property of both the form and controls is set to False
Verified that the form inherits from Form (as expected, as this is a standard installation and the first time I've used it)
Googled for help (nothing that worked)
Any suggestions would be appreciated.
It took some time but I finally found a workaround, if not an answer. As it happens, periodically my computer will stop allowing me to drag-and-drop anything. The solution to this is to press the Esc (escape) key, which instantly restores functionality.
I had this happening using multiple monitors.
Move VS to the main monitor (1) and all will work fine.
Greetz
I know this is an older thread, but this problem still persists. I am putting this here because I think some of these may work for others. The top option works for me, but is by no means a permanent solution. It helps to get your project completed though. Design your forms on your main screen then move VS to your secondary monitor to code kinda thing. I work off a laptop, so I don't like working on a small screen.
Some steps are rudimentary, but I was trying to be thorough. Sometimes it's the simple solution.
Preliminary troubleshooting...
Moving VS to main monitor(1) - this worked for me, but still doesn't allow me to use my 2 monitors
Run installer, select Repair
Run and cancel your project
Press the Esc button and see if things return to normal
Right click form "Lock Controls". This should not have the blue outline, or right click on form/control>Lock Controls and make sure nothing is locked.
Rebuild project, close and open the form again.
Snap to grid setting - Tools>Options>Windows Form Designer>General
Restart VS with 100% scaling - drawing may be an issue. I am not convinced it is not here since it works on the main screen but not the 2nd or 3rd
Dock property set to none for form/controls
Moving items very slowly with mouse - another indication drawing may be an issue.
Controls may not be docked in the container in which they reside. Restart VS. Try double clicking on the control, then move. I think this is indicative of creating the control outside a container(say, on a form), dragging it into another container(say, a tabControl) and then it not moving within that tabControl. Additionally, try creating new controls within their intended container and then trying to move them.
Close VS, delete C:\Users\user.name\AppData\Local\Microsoft\VisualStudio\15.0_xxxxxxxxx folder
Mouse driver - some software may cause issues here.
Absolute positioning - Tools>Options>Web Form Designer>CSS Styling>Change position...
Right click any item under toolbox and select "reset toolbox"
Requires Reboot...
Close VS. Delete some config files with current dates (devenv.exe.config, toolbox.tbd, toolbox_reset.tbd, toolboxindex.tbd, toolboxindex_reset.tbd) and reboot the PC. These are found in a directory like C:\Users\tdevy97\AppData\Local\Microsoft\VisualStudio\15.0_18c2eb4a where the last folder(15.0_18c2eb4a) is some random name. Reboot. Restart VS.
Corrupt toolbox? Close Visual Studio, Open the “c:\Users\AppData\Local\Microsoft\VisualStudio\14.0” folder and remove all the .TBD files, Start regedit, Find the “HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\ToolboxControlsInstaller_AssemblyFoldersExCache” and “HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\ToolboxControlsInstallerCache” keys, Remove everything from these keys leaving them empty, before you removing it, (back up your registry first), Reboot, Run Visual Studio again and wait until it recreates all items in the toolbox.
Last resorts...
Open command prompt as admin, navigate to your "IDE" directory (C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE) and run the following commands...
devenv.exe /resetskippkgs, it will clear all SkipLoading tags that have been added to VSPackages by users who want to avoid loading problem VSPackages.
devenv.exe /resetsettings, it will restore Visual Studio default settings. Optionally resets the settings to the specified .vssettings file.
devenv.exe /resetuserdata, it will take a couple of minutes to run as Visual Studio cleans up and sets itself back to its original state. You may open Task Manager at this point to check whether the devenv.exe process is still running. After it has completed running, you can restart Visual Studio.
devenv.exe /uninstall /force - complete uninstall. Reboot. Reinstall. Rock on!
In my case, I had to change the Dock property to None.
I had this issue and tried solving it using some of the aforementioned methods, including pressing Esc, rebooting, and deleting the folder in AppData, but none of these worked for me.
"Solution"
I have a dual screen setup, and what I eventually did notice is that if Visual Studio starts up on Screen 1 and is then moved to Screen 2, the components will snap back to their initial location after being clicked and dragged. After moving the Visual Studio window back to Screen 1, the components click and drag as usual. I am unsure of the cause of this since it never used to be a problem, but for anyone using dual/multiple screens, this may "solve" the issue.
I just found myself in similar, but slightly different situation - I could drag all controls without the "cross" icon such as buttons, but could not drag any control that had the "cross" icon such as group boxes and panels. One workaround that worked was to use the "arrow" keys to move the controls, but only a computer reboot fixed the issue. The solution, posted by Brett Wolfington did not work in my case.
Found a solution!!
I had the same problem:
Holding the mouse button and trying to move the element with no effects!
My solution:
Try after pressing the mouse button to move the element very slowely - it works!
I think it has maybe something to do with the mouse speed/acceleration settings. I changed them to the maximum. I guess VS has a problem with that. When i move the mouse slowely at the beginning then it works just fine!
Answer to a slightly different question, but my googling lead me here, so perhaps it helps someone else.
If no movement works, also not with keyboard, check the "locked" property. That was it for me in a colleagues project, so I was not aware he had locked it.
The controls also have a tiny lock icon so if you look closely you will notice.
None of these solutions worked for me. These are the steps that worked for me:
Close Visual Studio
Delete the Visual Studio AppData folder, usually at C:\Users\user.name\AppData\Local\Microsoft\VisualStudio. My folder was named 15.0_b148b13d, but your folder may have a similar name.
After deleting, Visual Studio took some time to initialize but I could finally drag the controls.
Seems its a drawing error. The controls actually moves, but there is a short time delay before you see it!

Visual Studio 'Data UI Cutomization'

In 'Data Source' window from where I can drag and drop data sources to a form, I can set the field to different control 'Textbox', 'Label', etc. But I used to be able to set them to some third party component (in this case Telerik's components). Just now I started to work on my project again, and these third party components do not appear there anymore.
I click on the choice list, customize ... I get the window 'Options' width 'Data UI customization' selected, there I used to be able to select Telerik's control, but again they don't appear there anymore.
How could I customize this ?
I ran into something similar back in December... apparently with some windows updated / service patches, it corrupted something. I couldn't even pick a UI control of my OWN. I even tried by creating a BRAND NEW project, created a single class and it would not appear in the toolbox to be put into a form anywhere.
By doing some digging, I came across a blog (don't remember where), but it directed me to do the following. Get to your Visual Studio Command Prompt. There should be one in your Startbar menus specifically under your Visual Studio icon group.
Once at the command prompt, do
DEVENV /setup
This apparently does some fresh "cleanup" settings and fixed whatever was stopping the classes from being displayed. As soon as I did, and re-started VS, the class libraries appears and able to be put into forms no problem.

C# component do not refresh when source code updated

I have a solution with many projects. One project contain few custom components. One of these components is used to display a title on an image. We can change the color of the background and many other things.
The problem is IF I decide to change the default color of the background of the component or change the position of the text, thoses change won't reflect in all other projects of the solution where the component is used. I have compilent the project of the component and all other projects Reference the component by the Project.
For the moment, what I have to do is to take off the component from the other project one by one and to add it back, then all is fine. Do you have a quick way to do it?
UPDATE
I have added a CheckBox inside that component and it seems that the checkbox is everywhere! Fine! But when a property has a some tag that let the component to change (example like the Background color) it doesn't change the "default" value but instead put the old value as a changed value in the property. So, I see the old value setted like if I add manually changed the color in the Properties panel when I haven't...
UPDATE 2
alt text http://img517.imageshack.us/img517/9112/oldonenewoneei0.png
Update 3:
This problem is still here. Just to let people know that I am still curious to find a way.
I have tried few of your suggestions.
If I clean all the solution and build only the project that has the Custom control then I build the solution. Nothing change (To test it, I have change the color of the component to Yellow. Nothing change : fail.
If I remove the reference and add it back to the project and then rebuild the solution. I can see the old color in the designer : fail.
I have updated the question with more information and an image (above) for those who want to try to help me.
As you can see, the old "compile" of the component show the Yellow background but when I insert a new component (from the Left Tool bar in Visual Studio) I can have the new component with the supposed WHITE background...
This is most likely due to references.
Your other projects probably copy in a reference to your component project. You'll have to rebuild these other projects for them to re-copy in the referenced component project, if it has changed. It is only updated at build time.
You can somewhat get around this by having them part of the same solution. In that case, you can set up your project dependencies correctly and it should handle things for you mostly automatically. But having everything in the same solution isn't always the right thing to do.
If you already have them part of the same solution or it's not a references problem, it might be due to component serialization. We've run into this quirk a lot when doing custom control development.
My guess is that the designer is smart and remembers the settings for the component as you have it in the designer and thus sees it as the default.
This doesn't sound usual. Right clicking on the solution and hitting "Clean Solution" might help (it will delete all dlls and executables from each project's bin directory, which forces fresh builds to occur)
You might also want to check your build order sequence.
I work on a project that has a similar problem, I have found that if you touch the .NET config file or assembly information file (depending on your project type). The other projects will then reflect the component change...
I'm not sure why this happens, but this is how I overcome it...
Recently I have switch to building everything via Nant, and that takes care of the problem altogether.
Sometimes the Visual Designer serialize all your properties in the code-behind, even if they have the default value.
If your component have a default backcolor of Red, and you change the default backcolor to Blue, the components that use your component will change it back to Red.

Categories

Resources