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!
Related
I have re-installed visual studio and the problem seems to be continued, I removed every visual studio related files including AppData(I am not meaning by entire AppData folder, AppData > Local > Microsoft > VisualStudio) and entirely removed folders with containing string "vs", "visual studio" in folder name except for visual studio code files in C drive, D drive, E drive. I even checked registries. I have one monitor.
This is not a really critical issue but its pretty annoying when I cannot use the move icon to move objects. Buttons can be moved but move icon doesn't seem to work at all for me.
Here's video how it looks like: https://youtu.be/NJlAwXp9aWw
As you can see my mouse gets snapped out of that button every time I click, and I cannot move with these buttons. I can use arrow keys to move, but if I do that I won't be able to use auto distance snap system at all. If I want that snap system then I'll have write down the size and resize it, and then re-write size in properties tab. This is too much work for me to just to move 1 object. I have to create and move at least 100 objects and I don't want to do this every time.
And I have read this question before: Can't Move Controls With Mouse on Windows Form Designer, and none of them helped me. I STILL can't drag anything except ones for not using move icons.
Try pressing esc in your keyboard or check if the locked property of the control is set to false.
i recently installed visual studio 2015 and made my first code in c#.
('maximized' for window state at the properties of the form)
everything went fine (comilation and testrun without errors) until i attempted to load one of the example tutorials, which i interrupted during loading.
after that i compiled and started my self coded application again from within visual studio. this time the output of the form was, unlike before, displayed half its size.
all the buttons including the window of the form appeared half its original size.
but when i executed the comiled application outside of visual studio (without it actually running) the application started in normal scale as intended.
this effect happens for this specific project only. if i start a new project the compilation & testrun will show a form scale as expected.
so my question: is there any magical setting that i have to change to end this nightmare ? i dont like to start all over again with a new project. i had set up 72 different button already. each buttonpress causes a different
SendKeys.Send("");
to be executed.
Check the Form's AutoScaleMode property!
The default is Font:
Controls scale relative to the dimensions of the font the classes are
using, which is typically the system font.
If that won't help do try to create a new project and copy the relevant cs-files into it!
In theory there is a zoom option in the VS designer, but at least in the Winforms desiner the shortcut does nothing for me.. It probably is for the WPF designer.
You did tag the question correctly and it is indeed about Winforms?
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.
I am totally stumped by this issue and I do not know what to do.
I have created a simple C# Windows Form application using Visual Studio 2012 Premium. I have a small program that starts up and creates a NotifyIcon in the system tray. On click of the tray icon, a context menu is displayed and it shows a few menu options (Options, About, etc.), where each option displays a form. I have added two icon files (.ico) via the Resources by right clicking on my Project item, Properties, Resources. I programmatically change the Icon of my NotifyIcon, alternating between the two different icons. My problem is that my old icons keep displaying, instead of my new ones that I've added to the project. To be clear, my issue is that OLD icons keep displaying--everything is working and there are no errors, it just doesn't show my latest icons.
The way I'm changing the icons in code is using:
notifyIcon.Icon = Resources.IconA03312014; //or the other one; the numbers are the date
I initially made my icons and used those and later decided to change them a little bit--I changed some colors, etc. So then I removed the old icons from my project by clicking the Exclude from Project option. Then I added my new icons, which had different names. Then I updated my two code references that load the icons to use the new names. No matter what I do, my new/updated icons are not displayed!
Whether I run the program in Visual Studio in Debug or Release mode, it does not matter. I can clean the solution, rebuild, and then run the executable directly by clicking on it in Windows, and no difference. Old icons are shown.
I have followed different sets of instructions online that explain how to clear the Windows 8 icon cache (three different methods). I have cleared the cached Notification tray icons as well, using two different methods.
Basically, I cleaned my solution and then closed Visual Studio. I kill all explorer processes, run ie4uinit.exe -ClearIconCache from the command line and delete the IconCache.db file. Then I delete the notification icon cache by editing the registry following instructions similar to these (http://www.sevenforums.com/tutorials/13102-notification-area-icons-reset.html). Then I shutdown the computer. Upon starting backup and rebuilding my solution and running, the old icons are still there somehow. The physical .ico files for the old icons were deleted long ago. Each time I've added new icons to my Resources, I've created new icon files from scratch (using icobundl.exe) and named them uniquely by including the date in the name. I am aware that Windows, and apparently Visual Studio also, like to cache icons and if you delete some icon file A.ico in Windows and then rename another icon file B.ico to A.ico, the B.ico file's actual icon will change to A's. Anyway, I don't the name of the icon file is the issue.
Now, in code, if I use the same strategy and set one of my form's icons, it works correctly and the form displays my latest icon, while my notify icon still shows the old (and now nonexistent, except in Visual Studio la la land) icon.
So, I have:
...
if(firstState){
notifyIcon.Icon = Resources.IconA03312014;
optionsForm.Icon = Resources.IconA03312014;
}
else{
notifyIcon.Icon = Resources.IconB03312014;
optionsForm.Icon = Resources.IconB03312014;
}
firstState = !firstState;
...
There are no errors and both the notifyIcon and optionsForm's changes, but the notify icon displays my OLD icon that no longer exists anywhere (except somewhere/somehow in VS). The form's icon changes to my updated/latest icon.
If I copy my app's .exe file to another computer and run it, it too displays the old icons for the notify icon, so the old icons are somehow still embedded in my exe generated by Visual Studio. If I just directly load the .ico file, instead of referencing my project resources, the new icons ARE shown. This have to be some sort of strange Resources caching issue in Visual Studio?
Can anyone please help me with this issue? I just don't understand how my old icons are still existing somewhere, and how Visual Studio somehow knows how to switch them! That's right, the above icon swapout works perfectly for the form. But for the notifyIcon, the icon does switch from "A" to "B", but it uses the old A icon and the old B icon--icons that do not exist anywhere anymore!
I hope I have explained my issue. I greatly appreciate any help that anyone can provide.
I had this same problem a few months ago and it drove me crazy for a couple of hours. I was so focused on clearing on the icon cache and thinking that it was just some sort of caching issue that it didn't immediately occur to me what the real problem was.
The answer, for me at least: Even though you have a 16x16 version of your image in your .ico file, Visual Studio will instead use the 32x32 image and scale it down to 16x16, causing it to look distorted. I say VS did it because when I ran the executable on other machines (different Windows OS's), I saw the same behavior so it wasn't a Windows 8 issue, for me. (It might very well be a Windows issue in general though, I don't know. I did not take the time to verify what was actually inside of the generated .exe--did it contain MY 16x16 version, or 16x16 version generated by scaling down my 32px version? That would have confirmed it, I guess...)
My "aha" moment came when I added a few rows of red pixels to each size of my icon image, in a different section of my icon. So I put the red rows in my 16x16 at the bottom. My 32x32 had the red rows in the center, etc. So then I added this .ico to my project and started the project up and BAM, there was a distorted version of my 32x32 icon being used in the system tray as my notify icon. There was no doubt about it.
If you notice that your notify icon (at 16x16) looks more distorted than you would expect, you might use a similar strategy to see if this same automatic scaling is happening. When I figured this out, my quick solution was to add a .ico to my project that contained ONLY the 16x16 version of my icon image. I then use that resource image only for my notify icon. Obviously, if you did this (have a 16x16 only image) for forms, for example, you would see a very distorted icon in your taskbar, Alt-Tab list, etc., because Windows has no choice in that situation but to create the different icon image sizes by scaling your 16x16 because that's all that you supplied. Anyway, in my particular case, as I believe is yours as well, there was no issue using the .ico for forms--they show the actual embedded 16x16 version of the image and there is no "automatic downsizing" of the 32px version.
That's all I know. I did not spend anymore time on this issue because I had to move on. I hope this helps someone avoid some icon frustration. Why, oh why, VS would you do this to us!?
i had the same problem with a splash screen.
some how it did not change after replacing the picture.
what i did is i remove the images then save the form.
run the app and there was no image.
then i replaced them and the problem was fixed for me.
so maybe you can try the same with you're icons.
hope it will fix you're problem .
Open the file Resources.resx of your project with the editor. There you have to change name="Icon1" into name="YourIconName".
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.