Windows 窗体应用程序中的停靠、锚点和流体布局 [英] Dock, Anchor and Fluid layouts in Windows Forms Applications

查看:24
本文介绍了Windows 窗体应用程序中的停靠、锚点和流体布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我被要求重新设计我几年前编写的旧应用程序.

So, I've been asked to redesign an old application I wrote a few years ago.

基本上,没有什么需要改变的,除了客户希望它更流畅,并且它必须是全屏的(没有可见的窗口"),即没有标题栏,只有一个无边框全屏窗口.

Basically, nothing much needs to be changed, except that the Customer wants it to be more fluid, and that it must be fullscreen (no visible "window") I.e. no Titlebar, just a Borderless fullscreen Window.

确保一切保持流畅的最佳方法是什么,我的意思是我们如何确保一切都出现在应有的位置,因为您知道,不同的分辨率、显示器尺寸等?

What is the best way to make sure everything stays fluid, I mean how can we make sure everything appears where it should, 'cause you know, different resolutions, monitor sizes etc?

这在网页/css中很容易,但这不是我以前做过的.大多数控件将在运行时以编程方式创建,基于执行的操作等.我将如何完成这样的布局?基本上,我希望能够全屏显示,而不知道他们的显示器有多大,或者他们使用的是什么分辨率.

This is easy in web pages/css, but this is not something I've done before. Most of the Controls will be created programatically at runtime, based on what action was performed, etc. How would I accomplish such a layout? Basically I want to be able to lay it all out full screen, without knowing how large their monitor is, or what resolution they're using.

推荐答案

在尝试使用响应可用空间大小和表单字体大小的流体布局来设计表单时,您当然是正确的.为此,您需要使用以下控件和控件属性.

Your certainly correct in trying to design your form using a fluid layout that responds to the size of the available space and size of the form font. To do that you want to use the following controls and control properties.

1, TableLayoutPanel 将一个区域分成一组行和列,并允许您将子控件放置在该表格布局的单个单元格中.这会响应表单宽度和高度的变化.

1, TableLayoutPanel will split an area into a set of rows and columns and allow you to position your child controls within individual cells of that table layout. This responds to a change in the form width and height.

2、FlowLayoutPanel 将从左到右定位您的子控件,并在空间用完时自动移动到新行.这非常适合流畅的设计,因为它会根据可用空间调整布局.

2, FlowLayoutPanel will position your child controls from left to right and automatically move to a new row when you run out of space. This is great for a fluid design as it will adjust the layout depending on the available space.

3、Control.Anchor 属性允许子控件根据表单客户区的大小改变位置和大小.所以你让你的控件总是从右边或底部边缘固定偏移.

3, Control.Anchor property allows a child control to alter position and size based on the size of the form client area. So you make your control always be a fixed offset from the right or bottom edges.

4、Control.Dock 属性会将子控件定位在边缘上,相反的大小将由包含表单自动定义.

4, Control.Dock property will position a child control against an edge and the opposite size will automatically be defined by the containing form.

这篇关于Windows 窗体应用程序中的停靠、锚点和流体布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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