I have a WinForm,when the its size is 700x700,when I change the screen resolution of the system from 1366x768 to other(like 800x600),only part of the window is visible.How can I make it fully visible? what property of the form i have to change?
I would say would say you want to adjust your Form.Size and Form.Location to fit within the Screen.GetWorkingArea(). You will want to do that when the event Microsoft.Win32.SystemEvents.DisplaySettingsChanged is fired. As in this answer.
You will want to adjust the Bounds property of your form. Screen.PrimaryScreen can support you to get the new right size.
Related
I need to access a WPF usercontrol's designheight and designwidth at runtime. I know this is impossible, so I'll explain why I want to do it, and hopefully someone can provide an example of the right approach.
From a C# winforms app, I open a new window containing a very large WPF usercontrol. If the monitor I'm running on can handle it, I want it to open the window at the full design size of the usercontrol. If the monitor I'm running on can't handle it, then I want to open the window as large as possible, leaving 1 pixel on each side of the screen. So I need to know the usercontrol's current design width and height before the usercontrol is displayed.
I want to avoid hard coding values in the winforms app, or using unbound public properties in the user control, because then I have to trust other developers to update them when they change the user control. I don't know if it's possible to bind a local variable to designheight or designwidth, or how to code that in XAML. Since I don't know a lot of WPF, there may be some other way to reach the goal that I don't know about.
Thanks for your help and advice.
Why don't you try something like Resize WPF Window and contents depening on screen resolution
The answer suggests that you bind the screen size to the window height and width. It will automatically size the window according to screen size. You can even set a % value for the size of the window.
I have a WinForms Application that was designed to support Full HD resolutions (so 1920x1080). Now this App is also supposed to run on a lower resolution: 1600x900.
Is there a way to let the application auto scale itself to fit the lower resolution? Like you would just downscale an image, basically resizing and relocating each control.
My current forms and panels have set their size to 1900x1080, so they just extend out of the screen on the lower resolution.
I have played around with AutoScaleModes and AutoSize, but the best I could get were Scrollbars so that you at least navigate through the forms. Is such a thing as downscaling an application even possible (retaining dimensions/ relative sizes and positions of the controls)?
Thanks in advance for any inputs on this!
If your main form starts in a maximized mode, it will adjust its size automagically.
But (and this is a huge "but" according to your question): the inner controls won't be scaled as you would see on a smartphone. WinForm is not "vector based" as WPF. If you have a fully loaded form in 1920x1080, when the main form is sized down, the controls won't fit and you will get scrollbars.
So the answer is: No.
The solution is available.
Form.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
and
Make all control autosize = false.
make a suitable size of your wish.
The property you are looking for is called Dock, it's a property of the controls.
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dock(v=vs.110).aspx
This basically tells the control how to fill the available space.
Creating a resolution independent application is not a simple logic. Everything in the window should be resize as per the selected resolution. Not only controls' size you have to change the font size also as per the changes. Here is the example how to create a resolution independent form using C# code. Another way is use DevExpress Tool. This tool provides Layout Countrol Container. You can place each control in separate layout item and assign the minimum and maximum size of control.
I set my control's position on form in resolution like 1280*1024 but when move my program to another computer with same resolution, control's position aren't in right place
why?
You need to use Docking and Anchoring instead of just placing them on the form. This will also help when you re size your form and maximize and restore the form.
Whenever I try to increase the form width in the properties box of VS 2008 it just resets my change back to 1300. It lets me lower the width, but not increase over 1300. How can I fix this? I have a datagrid in the form which has a width over 1300.
Windows in Windows cannot be larger than your screen resolution.
In code (eg, in the form's constructor), you can set any width you want, and it will be restricted by the end-user's screen resolution at runtime.
Your form should not need to be so big; consider redesigning your UI and/or using scrollbars.
you should check the Form.MaximumSize.Width property
Form.MaximumSize Property
so if you need to increase one of the two or both make sure that MaximumSize is also updated to your new values.
Edit: SLaks is correct that you cannot have the form bigger than the monitor anyway...
I have a custom styled transparent window and i've seen a lot of issues handling min/max/resize behavior when you use transparency and "WindowStyle=None".
When I tell my window to change it's windowstate to maximized it doesn't get it right so I want to override the logic there. It gets the width right but the height is all messed up and it doesn't know to add padding to account for a outerglow effect.
Without using win32 functions is there a SOMEWHAT EASY way for me to determine the "max viewport" or "max bounds" of the display that the application is running on top of? I think the short answer to this question is probably no but I figured I would ask anyways. I have my min/max width and height set up for the application and I figured if there was some function I could call to bring me back a x/y max bound then I could just set the window height and width to those values after I subtract the padding. My intention is to have supported resolution from 1024x768 - 1920x1080 so that this application can be displayed multiple places without reconfiguration.
Take a look at the Screen.PrimaryScreen Property. It has a method called GetWorkingArea which I think is what you want.
If there is more than one display, then there are methods to enumerate through the displays and find out which display the application is on.