AutoScaling WinForm Display (Small, Medium) - vb.net

First and foremost, please forgive me but my screenshots are in French due to my Windows installation at work. It is still very easy to understand though. I'll include screenshots to make it more visually appealing.
Here's some background information:
Windows 7 64bit
Visual Studio 2010
Default display is 100%
AutoScaleMode: DPI
AutoSize: True
My application is a windows form that was developped in a default (small - 100%) display. Like so:
As you can see, the "Petite" or Small display is the default selection.
Small Display - 100% (default)
Here is how my application looks with this setting. This is the correct display
Medium Display - 125%
The red rectangles point out the unwanted empty space.
I have tried:
Anchoring / Docking my controls such as my split containers, table layout panels, list views on Form_Load and via the UI. This didn't work.
Adding a split container to the form, and all controls respectively separated into it
Adding Table layout panels, where all textboxes and buttons are located in their respective cells
I really thought it was having a scaling problem because of the anchoring and docking. Although that didn't seem to be the problem ... What seems to be having trouble is the Tab Control and Listviews ...
Some users (most) have their settings as the default (100%) but there are a few who have it at a Medium setting, causing this scaling issue. Is there a way to fix this?

I cant see your screenshots or links for some reason so I cannot visualize the problem. If scaling is the problem, try setting AutoScaleMode to None.
I recently had to do this because my winform app was image intensive and it would not render correctly on Medium Settings because I built it using the default Small Settnigs display. Changing scale mode to None worked for me.

I fixed my issue by putting the tab controls and list views in a tablelayoutpanel. Everything that wasn't scaled properly had to be put inside a TableLayoutPanel. I kept my AutoScaleMode to DPI and AutoSize to True
Be sure to dock everything in their parent containers.
Here's the document outline for the more visual (like me):

Just click on the form and go to property pane. Find the Anchor element and click the dropdown. You click on all the lines in the square structure to become grey. Then click enter. Problem resolved.

Related

Windows Forms/Controls Resized on Wide Screen Monitor

Here at work I have been relegated to working on an old 4:3 monitor. The application I am working on in VB.NET (VS 2008) has several forms and controls that are sized to a specific height and width. They look fine on my monitor, but when I recently released a Beta for Users to try, the users that had widescreen monitors had stretched dialog forms and stretched controls on those forms. Is there a form property to set, or a programming technique to use, in order for the form and all of it's controls to display EXACTLY to the width and height specified?
I ended up fixing the problem myself by setting the .AutoScaleMode of the form to "None", and setting all my fonts to use pixels instead of points.
Unfortunately, this was not an issue of code, but rather of design. Sure, it's easy enough to post code snippets, but if I need to post a whole windows form application that's another story altogether.

How to have a TextBox control fill a Split Container panel?

I am running Visual Studio 2010 Professional (10.0.40219.1 SP1Rel) with no updates showing in Windows Update. When I drop a TextBox control into a Split Container panel, make it Multiline, then Dock in Parent = Fill, it shrinks down to 1 pixel wide and disappears. Of course, at runtime it is invisible.
Is this a bug? Is there a fix? I actually don't need text input - what I want is to display text in a resizable panel, with scroll bars. I could perhaps put code on the events (SizeChanged, SplitterMoved, SplitterMoving...) but that's an ugly solution. Is that the only one?
Apparently I didn't realize I had put a Flow Layout container inside the Split Container panel. This was preventing it from filling the panel.

Scale winform to lower resolution and all controls in vb.net

I made an application in Vb.net with winforms at a resolution of 1920x1080 not thinking it may need to run at a smaller resolution. When I run it at 1280x800 all the controls flows off the screen and doesn't fit even if I anchor/dock or use auto-sizing. I have tried putting my user controls in a panel and anchoring that too. Can you please give me advice on what I can do next, I'm out of ideas.
You could collapse or hide part of the form. Surely filling a 1080p panel is information overload. Also consider placing related controls in their own forms.

Automatically adjusting winform and controls to screen size

I created a winform application. The size of each screen is 1361, 768 in pixels. This worked great for larger screens and/or laptops. But now I have to move my application to 10inch screen tablets, which means my application does not fit.
I have never had to deal with this issue before, how can auto adjust each form size and adjust all of the controls and panels when viewing on smaller screens?
I am using VS 2012.
Making forms fully scalable in WinForms is possible, but it takes a bit of work. The good news is that most of this work is done at design-time, arranging the controls properly so that everything is done for you automatically by the framework. It's drudgery, but it isn't difficult. Rejoice that you don't have to write the scaling code by hand, form-by-form, like you did with VB 6.
There are four fundamental properties that you will need to acquaint yourself with:
Anchor
Dock
Margin
Padding
The last two should be quite familiar web developers who know CSS—they do the same thing here. Padding controls the inner margin around a control, while margin controls the outer margin. You will need to set these correctly to ensure that your controls can "breathe", because the automatic scaling code is just going to jam them up against one another.
The "standard" margins around a control in a Windows desktop application are approximately 12–15 pixels. You should make sure that you leave at least this much room. Then add additional margins/padding as you see fit to separate things. I keep these layout specifications bookmarked for reference. This is another good reference.
The next step is to instruct the layout manager how you want the controls to be arranged and resized. The key to this is to think in terms of container controls and child controls. The form itself is a container control, and you can set its child controls to either Anchor or Dock within its boundaries. One or more of those child controls can itself be a container control, and its child controls can be Anchored or Docked within its borders. The nesting is virtually unlimited, but for your own sanity and reasonable redraw performance, you'll want to keep it to a reasonable minimum.
A good way of doing this is to use the two provided invisible layout helpers, FlowLayoutPanel and TableLayoutPanel. Personally, I don't find the former very useful very often, at least not for standard Windows applications. But the TableLayoutPanel is invaluable.
Generally what I will do is fill my entire form with a TableLayoutPanel (margins = 0, dock = fill). Then I will add individual controls (or sometimes another nested TableLayoutPanel) to its cells. Those child controls will have their margins set appropriately, and will have either their Anchor or Dock properties set, depending on whether I want that control to have a fixed size or resize dynamically.
Before you get the hang of how these properties interact and how it all works, you'll probably need to play around with your layout a bit. Make a backup of your forms and then just dig in. Or, you might find it easier to start designing each form from scratch (you can still copy-and-paste individual controls in order to preserve their other properties). Eventually, it will all start making sense to you, and you'll be up and going in a jiffy.
The great thing is, once this is all set up, all you have to do is ensure that your form is resizable. Then, whether the user manually resizes it or uses the maximize/restore button, it'll automatically fill their screen size. This also works well for all DPI settings, which is another common Achilles' heel of WinForms devs.
Try to get the resolutions variables to adjust your screens, there is an answer to get these variables using the Screen class
Getting Screen Resolution
DevExpress has a great control call the Layout Control. This control helps to maintain consistent whitespace between controls as the form is resized. It does take a little study to use the control effectively but once you understand how to use this control the results are consistent and you are able to speed through form design.

how to resize or reposition controls based on screen resolutions in VB.NET

I making a Windows application with VS2010. Where i'm using panels to fight with different screen resolutions.
For some of my controls I used anchor property set to top,bottom without docking them to parent panel. when i run this program on the machine which is used to develop, result was as expected,But when i tried this one on different resolution its results were worse than expected. Some controls are partially displayed.
I found a solution here to this by re-sizing my controls based on screen resolutions. But that didn't worked for me as controls were re-sized but they were out of display area.
I couldn't relocate them based on resolution.
how would i set their position based on resolution.
or
i should assume minimum screen resolution (lets say 800*600) and program with this resolution.
Plz help!
I thought the solution was to use TableLayoutPanel and panels to do this.
I was bit right, but this doesn't work in all the cases.
Found a solution here https://stackoverflow.com/questions/2802015/....
Cheers..!