Everything in the form disappeared - c#

I have created an Windows Form. I have worked very hard on it. I inserted a bunifu button and the deleted it via Form.Designer.cs. The form and it's border still appears (I set border to none) !(https://imgur.com/AWltgCp)
It doesn't work at all.

There isn't a ton of info here. If the project is still open you could try to ctrl-Z your way back. Hopefully you are using some sort of version control. If so you could utilize that. Otherwise I believe we will need to see more code.

This is a problem that happens to me, quite often. But it depends on the code. So, first of all, post your code so we can see it and tell what is the problem. Now, by guessing, possible solutions:
Check your design code. See if you removed anything by accident. If yes try doing it the right way.
Try cleaning and rebuilding your project. Sometimes files can get corrupted and that can help.
Try pressing Ctrl+Z to undo and see if it does something. As #alphamalle said, you should have been using a kind of version control(git, etc.) so you could easily go back to your previous revision.
If all of these don't work, then sadly we can't tell. Please post your code, because the project could have been permanently deleted. Good lesson to use version control.

Related

VS2022 - Input issues

Either something has come undone in my brain overnight, or there has been a change to my instance of Visual Studio that I made by accident. I was running v17.3.1 and just updated to v17.3.4 to see if it would fix the issue, but it has not.
For the last few years of pushing out lines of sub-optimal code, I have gotten a space when I pressed the spacebar and a period when I push the period button. I use intellisense a great deal, to the point that when I want to log something, I type logger.in[tab] and I get logger.LogInformation written, waiting for me to type what I want logged.
This morning, my code was way worse than usual. I wasn't getting spaces or periods being typed to the screen. Initially, I thought it was my keyboard, but a quick test showed that my keyboard was fine. Then I noticed that when I would press either the period or spacebar buttons, the intellisense would complete the selection but not insert the space or the period.
Even trying to create a new variable is painful. Typing string[space]myString leaves me with stringmyString in the IDE.
Double tapping the space or period button feels really unnatural to me. Does anyone know what options I may have accidently changed, or how I can get it back to how it was working yesterday?
Thanks in advance.
EDIT: I thought I had fixed it with Edit -> Intellisense -> Switch between automatic and tab-only Intellisense completion, but then I had to double click on the autocomplete that I wanted for it to insert it.
You can open the visual studio installer and Repair the VS it will solve the problem.
This issue was caused by the Telerik extension, in my case "Progress Telerik UI for Blazor". This was reported to Telerik, who quickly published a new version.
The new version of the extension (2022.3.921.3) fixed this issue.

Visual Studio 2015 C# when typing it keeps going gray?

Whenever I attempt to write in VisualStudio2015 this occurs, where when I try to write, it works out fine for 1-3seconds, then the line I write on goes gray. It does not matter where I position my mouse, I tried with another keyboard to check if any keys were stuck, did not help.
This issue started to occur when I upgraded my PC to Windows 10. Tried several restarts etc.
Please help. This really gets annoying when trying to code :/
I am very bad at explaining my issue here, so please watch this gif to understand. Basically whenever I try to write, that line I am on grays out, leaving me unable to do so: https://gyazo.com/688a5660b29a3d93c0bb426715bcf038
Issue shown
After almost a month I found out the issue was that my CS:GO was opened meanwhile, and it somehow interferes with my Visual Studio and other programs. Thanks for your help though.

Coded UI thinks control is in a different position

I haven't been able to find someone else who has this same issue and it is extremely frustrating. Basically, for whatever reason, Coded UI is seeing a control in a different area then where it actually is. Like this:
Bounding Rectangle for Label with "IDLE" in it is up and to the left of the control
As you can see in the picture for some reason the Bounding Rectangle is up and to the left of the selected Label with the word "IDLE" in it. This is the first time I have seen this issue and after doing like 50 googles searches I decided to come here.
First off I am using Coded UI with a Windows Forms Application (I don't know if that makes a difference), it seems to do the same thing with all Windows Forms Applications, it has worked fine for all my WPF applications.
Second, no matter how many times I record my click on a button in my application or something of the sort, running the recorded method will always click off the button (due to it thinking the button is positioned up and to the left of the control). Up and to the left seems to be the only consistent thing, how much up and to the left varies based off of where the application is on the screen.
If anyone has any ideas or something I can try please help, I have no idea what is going on. If you need anymore information feel free to ask.
Thanks
Edit for Code sample:
public class Controller : WinWindow
{
#region Constructors
public Controller()
{
SearchProperties[PropertyNames.Name] = "My Sample C#";
SearchProperties.Add(new PropertyExpression(PropertyNames.ClassName, "WindowsForms10.Window", PropertyExpressionOperator.Contains));
WindowTitles.Add("My Sample C#");
enableWindow = new EnableWindow(this);
}
#endregion
public WinEdit CommunicationSetup
{
get
{
if(communicationSetup == null)
{
communicationSetup = new WinEdit(this);
communicationSetup.SearchProperties[PropertyNames.ControlName] = "Communication";
communicationSetup.WindowTitles.Add("My Sample C#");
}
return communicationSetup;
}
}
private WinEdit communicationSetup;
}
Extra Edit:
To Click on the thing I've used this:
Mouse.Click(new Point(obj.BoundingRectangle.Location.X + 20, obj.BoundingRectangle.Location.Y + 10));
and This:
Mouse.Click(obj);
Both click up and to the left of the control, as expected since the BoundingRectangle show there as seen in the picture
Edit: To replace "right" with "left" because I'm clearly an idiot and don't know my directions lol
Edit: Here is some more pictures showing the DrawHighlight() for the button Enable on my application, sorry I have to take a ton of information out for company policy reasons which might make it a little difficult to see what everything is going on but I have to
I also moved the application around so you can see how much of a difference DrawHighlight() has when the application is moved
Application dragged further down and to the right
what is stored in the obj variable that you try to pass to Click() method?
The problem might occur because you have not enough unique properties, who may definitely describe the control. Try to add additional SearchProperties. The most valuable would be a Control ID or Automation ID. If you cannot obtain this property on the wanted control, ask your development team to add it.
Try also to debug the method. Investigate of is returned in BoundingRectangle property of the control. Try out DrawHighlight() method. It will mark the position of the control with a blue rectangle. Another option would be to use TryGetClickablePoint() method. Maybe your control's size is bigger than you can visually obtain. The last but not least: examine your control from UIMap Editor and its whole hierarchy. You might find that the control you are looking for was badly recorded.
If nothing helps, then provide some more information and results of your investigation.
Good luck with that one.
Alex
I figured a consistent way to solve my problem, thanks to #Loathing for his comments on my question. Here is how I solved it:
var ret=new Rectangle();
GetWindowRect(obj.WindowHandle, ref ret);
Mouse.Hover(new Point(ret.X, ret.Y));
I still am not sure why this works so if someone sees this and understands feel free to comment and explain, I'm a little fuzzy on what goes on with GetWindowRect.
I recently came across some interesting results when trying to debug cross browser tests between IE and chrome that similarly mimicked what you've reported. It turns out that CodedUI and IE seems to be sensitive to the display scaling. I was using a multi monitor setup with different resolutions and changing each's scaling, using mostly 125%. The control's top and left coordinates were always off in IE and I could never figure out why. After doing some math and dividing by 125%, sure enough the number matched the coordinates it was supposed to be reporting. If I tried to change the monitor scaling without restarting windows, the issue got worse and I would also miss clicks. I imagine your solution to GetWindowRect appears be DPI sensitive as well, and reporting the correct coordinates with scaling taken into account.
Link to microsoft page that loosely discusses this:
Understanding Screen Scaling Issues
I get this all the time and the only way I managed to resolve it is restarting windows (go figure yet another MS solutions with Restart of the entire OS). Anyhow, in my case, it could be working fine, but later I would RD into my desktop from a laptop and everything would go nuts with this issue. I had to restart when working directly with PC and restart again when working from RD session.
I have had this issue fairly frequently as well. In my case whenever my code tried to download a file, the browser would popup the little download bar at the bottom. From then on, all my location rectangles would be off by the height of that bar.
My guess is that it is a bug in Microsoft's CodedUI that is unable to reset itself when the window it is testing changes sizes in certain cases. I have found a lot of bugs in CodedUI, I really hope that some day they get it more stable.
The fix for my issues so far has been to close the Internet Explorer window I was using to run the tests and restart it. CodedUI can't even get this right though, so I go out and kill all iexplorer.exe processes then re-start the browser.

Visual Styles magically stopped working

Does anyone know what can cause Visual Styles to just stop working? I don't know for sure when it stopped working, so it's hard to go back into time... I checked Program.cs and have EnableVisualStyles()
Yes I check the flatstyle as well...
I also saw, when looking for an answer, that if you run the exe outside of VS it should have Styles... It didn't work.
I created a new project and added all my references and "usings" and visual styles still work so i dont think its any of those things...
Does anyone know what might cause this?
Aha! My Startup Object got changed to the form instead of project.Program which is where EnableVisualStyles() is located.

.Net Custom Components "disappear" after file save

I might have a hard time explaining this because I am at a total loss for what is happening so I am just looking for some guidance. I might be a bit wordy because I don't know exactly what is the relevant information.
I am developing a GUI for a project that I am working on in using .Net (C#)
Part of the interface mimics, exactly, what we do in another product. For consistency reasons, my boss wants me to make it look the same way. So I got the other software and basically copied and pasted the components into my new GUI.
This required me to introduce a component library (the now defunct Graphics Server GSNet, so I can't go to them for help) so I could implement some simple graphs and temperature/pressure "widgets."
The components show up fine, and when I compile, everything seems to work fine. However, at some point during my programming it just breaks. Sometimes the tab that these components are on starts throwing exceptions when I view the designer page (A missing method exception) so it won't display. Sometimes JUST those components from the GSNet library don't show up. Sometimes, if I try to run it, I get a not-instantiated exception on one of their lines of code in the designer code file. Sometimes I can't view the designer at all.
No matter what I do I can't reverse it. Even if I undo what I just did it won't fix it. If it happens, I have to revert to a backup and start over again.
So I started to backup pretty much every step. I compile it and it works. I comment out a line of code, save it, and then uncomment that same line of code (so I am working with the same exact code) and the components all disappear. It doesn't matter what line of code I actually comment out, as long as it is in the same project that these components are being used.
I pretty much have to use the components. . . so does anyone have any suggestion or where I can look to debug this?
The only thing that comes to mind is a read-only bin directory. I've found that .NET has trouble if the interop libraries in the bin directory are read-only. Read-only interops generally prevent controls using those interops from displaying in the form designer and thus mess up compilation (if you do a full build anyway). A rebuild might let you get the app running and then fail when it reaches the part using the read-only interop.
This may or may not be your problem but it's all that comes to mind.
I know this is very late to the game, but I just ran into this same problem.
I'd pulled down one of our applications from SVN, and when I first tried to open the main form for editing, I was prompted with the custom component not being defined in the software, even though I could plainly see it as a class. I was given a choice to ignore it, which I did, and the custom control promptly disappeared from the form (still showed up in the project).
So at the suggestion of my colleague, I deleted the instance from my hard drive, and re-checked it out from SVN. Before i did anything else, I built the project for both release & debug, and that fixed the problem.
Maybe this'll help someone else who finds this SO question when they run into this.

Categories

Resources