I am building a project with the WindowsFormsApplication libraries and everything was going well until I noticed that the class properties are not being set at runtime anymore. The first instance occurred when I set menustrip hotkeys: the set in the designer, the code for it is there, I made sure nothing else would be sneakily altering the value(s) at runtime by using methods instead of the 'property' format. Then, somehow I managed to fix this by calling a method created specifically for setting menustrip hotkeys right after the initialization method.
NOW, the docking properties will not set or, in other words: I set a control's dock style to dockstyle.fill and when I maximize the window, it's as if the dock style was never set, but the code that says-so, is still there! the dock-fill property was working successfully only a moment ago...
I've searched for problems similar to mine for a good day and only found one result, but the questioner wasn't provided good answers ~in my opinion. I don't have much time so any help would be much appreciated!
In the mean time, I'll port all the controls over to a new form. That seemed to do the trick for two other occurrences with past projects...
I have had bizarre results with Visual Studio sometimes losing it's mind. Exiting and restarting seems to fix it. What version are you using?
Related
My Windows forms application creates the user menus at runtime given the user access privileges.
It works fine, but when the app is minimized, then all menus vanish. The space is used, but the names and icons are gone (obviously no sub-menu is shown, due to top level menu items are gone)
It is coded using the class ToolStripMenuItem and previously this code is set:
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Does someone have seen this behaviour?
Regards
Daniel.
Murphy's... Months stuck with this... and the solution was as simple as this:
When creating the MenuStrip objects I set the AutoSize property to false. I commented that line and it worked perfectly.
Thank you Reza Agahei for reading this and being concerned about this problem.
I can't understand fully why this happens... but what is working... musn't be even stared at.
I didn't post any code because the menus where generated through abstract model objects invoked through reflection, but I will follow your advice Reza, if I have another issue.
Thanx.
PS. I love this site, I always have found answers to my problems here, and now I'm happy to be part of it.
We're using a custom skin throughout our application. Recently, some folks here decided they don't like the way the groupcontrol looks. By bolding the caption and setting the groupControl's LookAndFeel.UseWindowsXPTheme = true, though, I make them happy.
Is there any way to set these properties in the skin (or elsewhere) so we developers don't need to manually set the group box control every time we use it? I loaded up our skin.xml file in the skin editor but nothing in that gui seemed obvious to me. From the documentation I've read, it sounds as though I need to make the changes on a pixel-by-pixel basis, more or less.
Having these properties set at design time would be nice.
We have a fair amount (dozens?) of groupControls already out there, so going back and modifying these two properties would be something of a pain.
Thanks in advance for any help.
As far as I know, there is no way to set these properties at design time.
I would like to know if there is a way to manipulate an App's UI live while running?
I am not a designer and I have many problems sometimes regarding matching colours etc.
The next problem is that anytime I would like to change e.g. the colour of a control I have to quit the App then go to VS2012, apply my changes, build and execute it again to see simple changes.
I know that I see any changes in the designer but I have to see the resulting screen to get an impression of the whole.
Is there a way to achieve this?
Add a secret keypress while Debug flag is set, that raises a form and allows you to select controls and expose a property sheet for them. Be a bit of work to get right, and a good stick of code even using reflection. Might be better off with a storyboard type app to do your designing.
Unlike styles in WPF which can be dynamically adjusted (which made this type of run-time adjustment simple), there isn't as elegant of a solution for Windows Store apps. Ideally, you'd have all of your UI and colors, etc. defined in XAML files and not settable through other means (as it becomes a longer term maintenance issue).
I'd suggest just adding enough test data and configuration so that you can see the look and feel of the pages (with colors, etc.) at design-time. Blend and Visual Studio are now quite good at showing a very reasonable near final rendering of the elements of the application. It's generally not too difficult to do anymore.
One thing I've done in the past was to make a single page/form that contained all of the styles and controls in a large scroll viewer. Then, we set it so it was configurable to the be the first thing to run. The tweak/build cycle was pretty fast, and the results were still very manageable.
I have a weird situation where I open a form from my application, hide it, and when I try to show it a second time, the Visible property says true, TopMost true also, location is correct, yet I can't see it.
Any ideas where and what to look at to work out what the problem is?
(Note: there may be issues with event handlers/delegate, but I'm not too sure where to start)
UPDATE - I set ShowInTaskbar to true - and I see it in the taskbar, but no way to bring it to front, and right click on the taskbar button does nothing. Alt-Tab neither. Doesn't show up in TaskManager.
Tried Crack.NET, but can't find any properties which let me get 'into' the object instance. .Net Memory Profiler doesn't help for this, I believe, and Winspector I'm not sure what to do with.
UPDATE2 - I lied, it's not directly a WinForm, I was inheriting from a custom class which in turn inherits from WinForm. I tried inheriting directly from Form and it works. So now I've got to go and look in the code of the custom class. I'll keep you posted...
Could it be out of the screen boundaries? (that is, moved out).
Use Spy++ or Winspector and try to find this missing window and see exactly where/why it's hiding.
OK, nailed it.
The Custom form class has a 'cool' function - it fades in and out.
But only once, apparently.
So the reason I couldn't see the form is because the Opacity was 0!
Is the parent Window visible?
Windows has rules about children of non-visible windows being non-visible whatever their own visibility.
For some strange reason, my toopltip in the VS 2008 C# winforms application shows up behind the form! It's very frustrating and I can't figure out what I should do. Anyone face this before? Ideas?
(PS - I'm doing a toolstip.show programmatically within the form)
There are a few things you might want to check:
Make sure the tooltip knows what its parent window is.
Make sure the window the tooltip belongs to is in the foreground (no, this isn't a requirement for displaying tooltips, it just helps debug.)
Try giving focus to the owner of the tooltip. If that fixes the problem, then there's probably an ownership problem with your tooltip.
Try bringing your page element to the front. (Right click on element, bring to front). Is this happening on all tool tips you have configured? And no, I have not seen this before
There is a similar (and known) problem with tooltips appearing behind the Windows task bar. The problem is sporadic and I have never seen a solution. If you're also seeing this behavior sporadically (and I suggest that you try this on different machines), then it may be related. Otherwise, if the problem is consistent across multiple machines, let's see your code, because you're probably doing something wrong.
I have a similar issue. I have a user control written as C++ WTL, being used in a C# .NET2 app. If the control is just on the form then the controls tooltips work fine, however if the user control is on a panel or in a group then the tooltip is behind. I've tried changing the WTL code to force the tip to the front, this works but causes issues with lost focus/selection in other controls.
This problem is almost always caused by the window being TopMost. Try using SetWindowPos to set your tooltip to HWND_TOPMOST. I haven't tried this though...
I've seen this issue happen in both Windows.Forms and Delphi (native windows) based applications, caused by the interaction of "stay on top" with the Windows API.
Essentially, marking a form as TopMost makes it stay on top of some windows, but not others - Window management has more than two distinct levels.
What I found is this: my applications would behave themselves when run normally, with tooltips showing on top. Problems would occur when switching to- and from- other applications - somehow the "TopMost" of the windoww would become "very-ultra-top-most" (non-technical term ;-) ) with the tooltips appearing behind the window.
Having described the problem, I'd like to offer you a solution - but I never did find a good one. Sigh.
Hope that the additional information will be enough for you to find the solution you need.
I have seen this happen on Windows XP, particularly on the taskbar.
Are you sure it's an issue with your application, rather than the OS?