Visual C# Express 2010 ToolStrip buttons losts icons after restart - c#

I have really weird problem. In my simple project in c#/winforms I had ToolStrip with inserted standard buttons. It was all ok but suddenly after one restart icons just disappeared. Buttons were still there but with no image.
I was pretty shocked by this and couldn't find any bug. Well, I added another ToolStrip with standard buttons. Icons were there. I noticed, that in Designer.cs file new buttons definitions had line:
this.newToolStripButton1.Image =
((System.Drawing.Image)(resources.GetObject("newToolStripButton1.Image")));
Unfortunately after restart those lines just disappears aswell as the icons.
What could be the problem? How to solve it?

Just had a similar problem where my ToolStripButtons dis-attached themselves form the ToolStrip. I was going along nicely, compiled and ran my program and the ToolStripButtons simply went AWOL.
Doing a web search, this seems to happen occasionally without any real answer as to why.
Looking in the designer file, the 'this.myToolStrip.Items.AddRange' command had disappeared from myToolStrip section of the form, but the buttons where still there.
To fix, I simply added it back (in the Designer file)...
this.myToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.myToolStripButton1,
this.myToolStripButton2,
this.myToolStripButton3,
this.myToolStripButton4});
To get the format, just add a new button to the existing ToolStrip and search the designer for 'AddRange'.

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.

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!

How can I make Visual Studio use my updated icon for my NotifyIcon?

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".

C# Tool disappears from the design

I have a ListView that just disappeared from the design page of my Form1. I have not deleted it or touched anything regarding ListView's code. I was actually working on my MessageBox. Actually, I have another
I have had this happen to me before and it got fixed by clicking Ctrl+Z (Undo), but that doesn't help now.
A little bit of research showed me that this is a known bug from VS2010, but I am using VS2012. Windows 7 x64.
Using listView1.Show(); in the code does show the ListView after I start the debugging, but if I want to edit it in the designing I have no way to access its properties (other than the code).
A simple workaround you can try is,
Select the control in the DropDown of Property Window
Press ESC key
Press Ctrl+X
Press Ctrl+V
When press ESC key, Visual Studio moves focus from property window to form designer. At this point control is still selected you can see it in the dropdown of property window. Then when you press Ctrl+X you actually Cuts it, and then on pressing Ctrl+V you paste it again on form. Which causes the control to be added on form again.
I hope it may solve your issue.
A small workaround I found - delete the form from the form design (the place with the tools in the sidebar) - this will get rid of any code you have in the designer.cs file. After that just type in and create everything from scratch.
If you have an old element with ton of properties that disappears after you do something, but you can still restore with Ctrl+Z you can try to Copy its code from the designer.cs file and then Paste in the Form1.cs file and changing it according to your needs.
Yes, it sucks, but it's the only solution I managed to come up with.

Can't select controls on my form

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.

Categories

Resources