I've created a Windows form in Visual Studio 2019 that looks like this at design time:
At run time, though, the bottom half of the form is unceremoniously truncated:
The dimensions of the form (its Size properties) are height 800, width 640.
What do I need to do to get the entire form to display at runtime?
Related
I have a TreeView (System.Windows.Forms.TreeView) control on a custom control (similar to the Output window in visual studio 2013). that control is placed at the bottom of a main form (like the visual studio ide). when i populate this TreeView control with data, it fills correctly, but, if the containing control is close to the bottom, the displayed "popup" is cut off. if i expand the lower control to have more room, the control displays with all the data. the display is "docked" to where it was designed. i tried putting a scrollbar on the display (which worked), but this is not the desired/requested behavior.
what i would like to do is to either have the display "go up", if necessary, like the "Show output from:" display on the Output window in Visual Studio 2013, or, simply have the display be FreeFloating.
any suggestions would be greatly appreciated.
thanks in advance.
pete.
RESOLVED:
- create 3 new variables ... originalParent, originalLocation, and firstTime.
- in the Resize method (which is called from a mouseOver event), where the size of the display is set, if this is the first time, save off the above and set the parent to the TopLevelControl
- determine the new location on the form ... originalParent.FindForm().PointToClient(originalParent.PointToScreen(originalLocation).
- see if the displayed output would go beyond the end of the top form ... TopLevelControl.DisplayRectangle.Height - (locationOnForm.Y + oTreeView.DisplayRectangle.Height)
- if the difference is less than 0, adjust the new location.Y by the difference.
- set the display output Location to the new location
presto ...
also, added a method so that when the main form is resized, or the containing control is repositioned, the location is set using the info above - just not adjusting for the display output height.
add a call to the reset in the mouseLeave event
I come from a WinForms background, so WPF is foreign to me. I am experimenting with it and trying to make a simple Hello World! application, except that the application displays different at runtime than how it is in the designer.
What I mean by that is I have a 'Hello!', and in the designer the location of the button is 12, 12, and and the Window is sized so that is the right/bottom edge of the button is 12, 12 pixels from the right/bottom edges of the window (so there is uniform 12 pixels around the button). When I run the application the button is still 12, 12 pixels from the top & left edges, but is 27, 27 pixels from the right/bottom edges of the Window. I have verified that the button dimensions are correct (I took a screenshot and measured the button in Adobe Photoshop and verified that the button width & height in the XAML code was the same as what was displaying on the screen). The Window is what is growing bigger.
I also verified it was not the canvas getting bigger by explicitly setting the width & height, changing the background color, and setting horizontal/vertical alignment to left/top. So when I ran it again, the canvas stayed the same size, but the Window still had an extra 15 pixels on the right/bottom.
I have tried Googling & searching here for this problem, but can't find an explanation as to why runtime is different from the designer.
I should note I am using Visual 2010, and I am using a simple for the layout.
Anyway, thanks for any clues as to why I am getting 15 extra pixels.
(Note I'd post a screenshot, but as a new user I'm not allowed).
You can use a tool like Snoop to diagnose this. It should allow you to inspect the entire visual tree of your application, and determine which UIElement is responsible for the extra pixels.
I've got a lot of information to display in a small area and I would like to space this text as tight as possible without overlapping. There is a grid snap in the Visual Studio Win Form designer. But, this is what I'm getting:
Is there a way to adjust the grid snap in the Visual Studio 2010 Windows Form Designer? Or is there a way to make sure that labels are 'leaded' as tight as possible?
Thanks, as always!
Found the answer here: Change spacing of snaplines in Visual Studio
Apparently, there isn't a 'universal' grid snap. It's adjusted for each item. Weird.
Use a TableLayoutPanel adjust its Rows to your requirement (e.g size to absolute 20 pixels), insert Lables in each row and adjust Lable's Anchor/Dock, Margin, Padding, and TextAlign. This is the best you can get with Winform I guess. You can also have a look of WPF which will give you more control of the visual settings.
I am developing a custom control in WPF/C# that involves a scale. The scale shows numeric labels (TextBlock instances) at key ticks along the scale as one would expect.
When doing some manual testing I came across a strange scenario where if I have just the right size of control a particular scale label becomes garbled.
Here is a link to a screenshot:
If I re-size the control a single pixel then it all works as expected.
Any idea what is happening? Is it just a WPF bug?
I am trying to remove the border of my WPF window in the design view/tab in Visual Studio. Please don't mistake this as a request to create a border less WPF window. I did that and it is working fine. What bothers me is that even if you have set WindowStyle = None, ResizeMode = NoResize, the design view/tab still shows a border around your window in the preview.
Is there a way to remove said border and have a 1:1 preview of the border less window as in Windows Forms?
Every question I have found in regards to this only asks how to remove the border of the actual application. I would like to remove it in the preview.
Any help would be very much appreciated :)
here is a screenshot of my problem:
This cannot be done as this is just how Visual Studio renders a window in design view (I think the frame is probably there so that you can distinguish when you are editing a Window rather than a UserControl).
Rather than try and find a solution to this I would ask myself if this is something I need to be spending time figuring out - after all you say that your program works correctly when being run. I think your time will be better spent writing code for your program rather than trying to play with the design time environment.
Update: In response to you comment, consider that the window frame will be different on every users machine depending on their operating system version (XP vs. Win7) or the theme the user has installed.
My computer has XP installed so the side borders are a lot thinner than those shown in design time so any content will be smaller (but only my a few pixels - 4 in my case; does your user interface design really depend on 4 pixels?).
When using a technology such as WPF you should not be designing your UI to fit to exact pixel sizes; you should be designing with min / max values or using layout containers that adjust to the size of the window as set by the user. Any regions in your UI (E.G. sidebar and main content) should be expressed as a ratio or percentage of one another; instead of saying "The side bar is 150 pixels wide and the main content area is 350 pixels wide" you should be saying "The side bar takes up a third of the window width and the main content takes two thirds".
Although the question is very old and have already been answered (kind of), I just realized: if you set WindowStyle="None", your undesired border is gone.