如何根据系统分辨率调整win form应用程序的屏幕 [英] How to adjust screen of win form application According to System Resolution

查看:76
本文介绍了如何根据系统分辨率调整win form应用程序的屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我正在申请表格申请。



我正专注更多关于用户界面,我遇到了一些问题。



一个大问题是屏幕分辨率。

在开启项目时我的电脑屏幕分辨率为1024 * 768.

当我将屏幕分辨率更改为最小值或最大值时,我的win表单应用程序屏幕设计会受到干扰。



我试图根据屏幕分辨率调整win form屏幕。



怎么做?



请帮助

Hello,

I am working on a win form application.

I'm focusing more on User interface and I am facing some problems.

One big problem is of screen resolutions.
While devloping the project my computer's screen resolution in 1024 * 768.
When I change the screen resolution either minimum or maximum my win form application screens designs are getting disturbed.

I am trying to adjust win form screens according to screen resolutions.

How to do this?

Please help

推荐答案

您可以调整控件的 Dock 属性,这个属性可以调整大多数控件(例如DataGridView,Panel,Label(用作标题))。但是这个属性无法调整所有控件。



最好的问候,

Theingi Win
You can adjust your control's Dock properties, this properties can adjust probably most of controls(eg DataGridView,Panel,Label(use as Header)).But this properties can't adjust all of controls.

Best Regard,
Theingi Win


如果不是im,这是非常困难的可以在WinForms中执行:在WPF中很容易。



您可以使用Anchor属性来扩展和收缩控件,但除了简单的形式无法提供帮助许多。 很好地做到这一点的唯一方法是使用围绕单个内核的边缘框架,就像Visual Studio一样 - 也许正是出于这个原因!



很抱歉,但是他们是休息!
This is very difficult, if not impossible to do in WinForms: easy in WPF.

You can use the Anchor property to expand and contract controls, but except in simple forms that isn't going to help much. The only way to do it "nicely" is to use edge located frames around a single inner core, in the same way as Visual Studio does - and probably for just that reason!

Sorry, but them's the breaks!


为resize事件创建一个eventhandler(属性窗口> events或this.Resize + = new EventHandler(somefunction);)然后调整大小/使用this.ClientRectangle中的新维度重新定位表单上的所有控件。



示例:



Make a eventhandler to the resize event (properties window > events or this.Resize += new EventHandler(somefunction);) then resize/reposition all controls on your form using the new dimentions found in this.ClientRectangle.

example:

private void PersonalizeColumnsForm_Resize(object sender, EventArgs e)
{
    listColumns.Top = 10;
    listColumns.Left = 10;
    listColumns.Height = this.ClientRectangle.Height - 20;
    listColumns.Width = this.ClientRectangle.Width - 30 - btnClose.Width;

    btnClose.Left = 10 + listColumns.Width + 10;
    btnClose.Top = 10;

    btnCheckAll.Left = btnClose.Left;
    btnCheckAll.Top = btnClose.Bottom + 10;

    btnUncheckAll.Left = btnClose.Left;
    btnUncheckAll.Top = btnCheckAll.Bottom + 10;

    btnTop.Left = btnClose.Left;
    btnTop.Top = 20 + (listColumns.Height / 2) - 35 - btnUp.Height;

    btnUp.Left = btnClose.Left;
    btnUp.Top = 20 + (listColumns.Height / 2) - 5 - btnUp.Height;

    btnDown.Left = btnClose.Left;
    btnDown.Top = 20 + (listColumns.Height / 2) + 5 + btnDown.Height;

    btnBottom.Left = btnClose.Left;
    btnBottom.Top = 20 + (listColumns.Height / 2) + 35 + btnDown.Height;

    btnReset.Left = btnClose.Left;
    btnReset.Top = listColumns.Bottom - btnReset.Height;
}


这篇关于如何根据系统分辨率调整win form应用程序的屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆