So I'm working on a card maker for a TCG. I seem to have encountered a very odd glitch and can't find a decent workaround. I have several panels that contain various controls for determining the different variables of the card, like so:
However, I've noticed that if I go into the Form1.cs file and change code--any code at all, from adding/removing comments to deleting and restoring a semicolon--and then go back into the design view, the design view window goes black for a moment whilst it redraws everything, and then pops back into place...except that the right-hand side of various panels has been bumped to the left about 5 pixels. It doesn't seem like much, but after multiple changes, multiple swapping back and forth between windows I get this:
...which of course is hideous and unusable. For a long time I couldn't determine why some panels did it and others did not, but finally while reworking the Keywords tab you can see in the screenshot, it dawned on me that it was any panel that I have set to anchor both on the left and right hand sides of the parent control. This is to allow the user to resize the window to their heart's content. I currently have a kludge in place in which I modified Form1.Load() to hard-code the size of the affected panels. This is of course entirely against the whole point of using a visual editor in the first place.
The hierarchy of the controls goes Form1->SplitContainer->SplitContainer.Panel2->TabControl->StatsTab->StatsPanel. This unfortunately doesn't appear to be a code-based problem since I don't write any code to affect this. The redraws apparently actually change the StatsPanel.Size property, and if I cycle back and forth I can watch it sloowly decrement.
So, does anyone know what might be wrong? I don't like to jump to "oh Microsoft has a glitch in their editor" but I can't find anything else that I am doing or setting that could be causing it. Any help would be most appreciated.
Related
I'm encountering a new phenomenon (I've never seen it before), after hiding a control and switching tab it moves super slow and some times I can even see the hole the hidden control left on the same spot in the different tab.
and even pop up a file dialog take a very long time after the operation.
(I've seen similar question not exact and none of the solutions seems to work in my case)
*) the controls I'm hiding are simply in a group-box container no data grid or such.
Any suggestions?
Thanks!
I have searched around using different terms, I don't know the correct name of what I search so it's hard to find something relevant about it.
In Winforms when you drag a control into a form and drag it around if there is another control you will see visible lines in the designer (snap lines I think) that are showing the alignment from the control you are dragging to the other. In WPF there was the same but I don't have it anymore and I can't find it anywhere in the tools/options. I did not change anything to my knowledge that would change that behavior.
Is it due to an update and they removed it or what happened that I don't have it anymore?
See bottom, left side of the designer. There are a couple of toggle buttons there which may be of help.
Who fancies a challenge?
I'm currently working on the ControlTemplate for a chromeless Window which will be a part of a reusable theme assembly. I want the behaviors for moving, closing, minimizing and restoring to be implicit so I've written attached behaviors for this functionality which I've then included in the template.
Now,..I've come to resizing and I've come to a junction. For better or worse I'm handling the mouse move in the behavior and finding whether the cursor is inside the resizing 'zones'. I'm far enough to change the cursor appropriately but now I've gotten to actually resizing the window there are three options I've come across.
I could hand-ball the affair and adjust the Left & Top and Width & Height as needed. This is the simplest option and is easily achievable using attached behaviors but it seems like moderately heavy lifting and I understand that WPF will continue to render as the window is adjusted causing flickering,..which sucks.
The second option is to get a message hook and listen for WM_NCHITTEST and the like but the solutions I've found so far involve me sub-classing Window and I don't want to force consumers of the theme to use any controls that aren't framework provided.
The last option is to somehow draw a rectangle on the screen showing the are the Window will take up as the mouse is dragged and then resize on MouseUp,..which seems doable but it's not something I've done before so some pointers on that would be cool.
So,..what should I do? The Win32 route seems like my best option so far but I'd rather not if someone has a 'purer' solution that works. I'm happy to get suggestions with option 3 and anything right up to .Net 4 in case some dynamic magic might be possible.
Thanks in advance.
I started noticing strange behavior when navigating the main toolbar of my Winforms application, and I don't know how to fix it. When I initially open the dropdown of the File menu, it looks like this:
I begin to scroll down each item with the arrow keys, and everything is fine until I reach "Exit". As soon as I hit the down arrow key from "Log Off", or if I hit the up arrow key from "Open", the menu rearranges itself to look like this:
I'm puzzled by this behavior. The menu still works, and from this point, if I start scrolling up, I can get the arrangement back to normal:
A few observations:
The menu still works.
This doesn't happen when using the mouse.
I have some code that toggles the Visible property of some of the menu items. I was able to modify what the arrangement was by playing around with this, but it was still messed up.
Can anyone help me understand what is going on, and how to fix it?
I found the source of this problem. It is a known bug that Microsoft apparently doesn't intend to fix. The problem happens when you attempt to toggle visibility/availability of menu items during runtime. Microsoft reminds us that "this issue is purely visual, there's no functionality loss."
Their suggested workaround is to add/remove the menuitems rather than show/hiding them.
Another workaround is suggested on the forums: deriving from ToolStripDropDownMenu, turning off AutoSize, handling it on your own, and adding 1 extra pixel of height.
I found a blog post that addressed this issue, but the author never got around to posting his solution. He makes a useful point concerning Visible vs Available, however.
I am trying to create a panel which will have a set of "buttons" on it.
These buttons should have the following behaviour:
Appear similar to a tag (with
rounded edges)
Contain a red
cross to remove the filter/tag from
the panel, similar to the way internet
explorer tabs have an embedded cross to close the individual tab.
allow the user to click
on the tag and respond like a normal
button (as long as the click is not
in the red cross)
Number 1 is no problem, this is just appearance, however, regarding numbers 2 and 3, I am not sure if there is already code out there do to something similar...and I dont really want to reinvent the wheel if I can avoid it!
My question is: Does anyone know if there is something out there in infragistics which will do this simply, or will I need to write this myself by subclassing winform buttons?
Thanks in advance!
Is this new development or maintenance of an existing project?
If it is maintenance, you have a somewhat tougher time ahead. You'll implement a UserControl, probably segmented into two buttons. Use docking to get the behavior as correct as possible. The far right button would contain your cross image; the left (which would need to auto-expand as you resize the control) would contain your primary button behavior. Play with the visual styles until you get them right (EG, removing borders, etc).
If this is new development, and you haven't gotten too far into it, you might consider using Windows Presentation Framework (WPF) instead of WinForms. It will be easier to build the control and get it to look exactly how you want it. WPF includes an extremely powerful control compositing system which allows you to layer multiple controls on top of each other and have them work exactly as you'd expect, and it carries the added advantage of allowing full visual control out-of-the-box.
Either way, this is more work than dropping in an external component ... I've used Infragistics for years, and I can't think of anything they have which is comparable. The closest, but only if you're building an MDI application and these controls are for window navigation, is the Tabbed MDI window management tools -- and there, only the tabs (which replace window title bars) have this behavior.
I don't think that infragistics can do something like this. The UltraButton control can't.
Implementing a own control wouldn't be that hard.
your probably going to have to make a costume control for this type of work.