首页 \ 问答 \ 当表单最大化时,如何使表单上的所有控件扩展并按比例增加?(How can I get all controls on a form to expand out and increase proportionally in size when form is maximized?)

当表单最大化时,如何使表单上的所有控件扩展并按比例增加?(How can I get all controls on a form to expand out and increase proportionally in size when form is maximized?)

我在IDE的设计时有一个相当大的表单(905 X 813)。

我添加了此代码以使表单全屏:

private void Form1_Load(object sender, EventArgs e)
{
    TopMost = true;
    FormBorderStyle = FormBorderStyle.None;
    WindowState = FormWindowState.Maximized;
}

...但是控制装置拥抱西北角并且仍然留下了很多“死角”,因为这个形状被磁化到西北角,而不是它的控件尺寸增大。

如何让控件在所有方向上展开,填满整个屏幕?

这不需要考虑不同的监视器大小等 - 它只是一个模型。

我试图将外部面板的Anchor属性设置为中间/“全部”设置,但它不允许我 - 它保持在“顶部,左侧”......?!?


I have a form that is pretty large in the IDE at design time (905 X 813).

I added this code to make the form full screen:

private void Form1_Load(object sender, EventArgs e)
{
    TopMost = true;
    FormBorderStyle = FormBorderStyle.None;
    WindowState = FormWindowState.Maximized;
}

...but the controls hug the Northwest corner and still leave a lot of "dead space", as the form is magnetized to the northwest corner, rather than its controls growing in size.

How can I get the controls to expand in all directions, filling the entire screen?

This doesn't need to take into consideration different monitor sizes or such - it is simply a mockup.

I tried to set the outer Panel's Anchor property to the middle/"all" setting, but it won't allow me - it stays on "Top, Left"...?!?


原文:https://stackoverflow.com/questions/38383479
更新时间:2020-10-16 21:10

最满意答案

这对我来说并不太清楚......你可以利用ANCHOR,使LEFT和RIGHT能够使控制向正确的方向发展,并禁用LEFT使其“遍历”整个表格。 当然,对每个控件执行任务,您将获得所需的位置/大小。

无论如何,您可以使用变量手动索引所有控件的所有位置和大小以获得WIDTH和HEIGHT并计算一种索引。 这是一项艰巨的任务,但它可以让您精确控制每个控制位置和高度。

如果你想要保持所有比例(我的意思是,改变他们的FONT大小)的redim控件,也许这段代码可以帮助你: http//www.codeproject.com/Tips/1025766/VB-NET-Dynamically-Resize-和重新定位-全对照


It's not too much clear to me... You can utilize ANCHOR, enabling LEFT and RIGHT to make the control grow to right direction, and disabling LEFT to make it "walk" through the form. Certainly doing a task on each control you will achieve the desirable position/size for them.

Anyway, you can manually index all positions and sizes of all controls using variables to get WIDTH and HEIGHT and calculate a kind of index. It is a big task to do but it enables you to control exactly each control position and height.

Bu if you want to redim the controls keeping all proportions (I mean, changing their FONT size), maybe this code may help you: http://www.codeproject.com/Tips/1025766/VB-NET-Dynamically-Resize-and-Reposition-All-Contr

2016-07-14

相关问答

更多

窗口最大化/未最大化时的事件(Event when a window gets maximized/un-maximized)

你可以通过覆盖WndProc来做到这一点: protected override void WndProc( ref Message m ) { if( m.Msg == 0x0112 ) // WM_SYSCOMMAND { // Check your window state here if (m.WParam == new IntPtr( 0xF030 ) ) // Maximize event - SC_MAXIMIZE from Winus ...

Pyforms - Form似乎总是最大化(Pyforms - Form appears always maximized)

我也找不到一个好的解决方案。 对于临时解决方法,当我想避免默认最大化时,我所做的是修改C:\ Python27 \ Lib \ site-packages \ pyforms \ gui \ standaloneManager.py。 从 if geometry is not None: w.show() w.setGeometry(*geometry) else: w.showMaximized() 至 if geometry is not None: w.sh ...

取消最大化表单的大小(Un-maximize size of the form)

好吧,如果您需要非最大化事件与设计器大小不同,那么只需在OnLoad覆盖中设置它: Protected Overrides Sub OnLoad(e As EventArgs) MyBase.OnLoad(e) Me.WindowState = FormWindowState.Maximized Me.Size = New Size(800, 600) End Sub Well, if you need the un-maximized event to be different ...

使用FormBorderStyle none的表单,在最大化时变为全屏(Form with FormBorderStyle none, becomes fullscreen when maximized)

这是FormBorderStyle设置为None的默认行为。 要以您希望的方式获得它,您可以设置Form的MaximizedBounds属性以匹配WorkingArea : Me.MaximizedBounds = Screen.FromHandle(Me.Handle).WorkingArea This is the default behavior with FormBorderStyle set to None. To get it the way you want you can set ...

Delphi:MDI应用程序中最大化的子表单(Delphi: Maximized Child Form in MDI Application)

通常,MDI主窗体的客户端空间应自动计算到没有菜单或条形的空间,前提是这些条形对齐到窗体的边缘。 当条形图或其他控件未对齐时,您确实需要自行调整。 处理WM_NCCALCSIZE以告诉窗口您的表单偏离客户端矩形维度。 或者看看NLDExtraMDIProps ,其中我在WParam WParam and $FFF0 = SC_MAXIMIZE时捕获WM_SYSCOMMAND以调整MDI子窗口的大小。 该组件提供了一些额外的属性,如:BackgroundPicture,CleverMaximizin ...

当用户最大化窗口时,在eclipse中增加表单的大小(Increase the size of my form , when user maximizes the window, in eclipse)

使用Layout而不是setBounds调用。 GridLayout是一种可能性或FormLayout 。 就像是: ScrolledForm scrldfrm = managedForm.getForm(); scrldfrm.getBody().setLayout(new GridLayout()); scrldfrm.setText("Hello there!"); Section section = managedForm.getToolkit().createSection( ...

根据表单大小在窗体上定位控件(positioning controls on a windows form according to the form size)

每个窗口控件上有两个属性控件Dock和Anchor使用这些属性可以精美地放置控件并测试不同大小的表单。 检查这些链接,并通过玩这些属性来查找行为。 锚和码头 码头控制 There are two properties on every windows form control Dock and Anchor Using these you could beautifully place controls and test for different sizes of forms. Check th ...

访问 - 如果表单最大化,则允许滚动条(Access - If form maximized then allow scrollbars)

我管理,在调整大小事件代码工作正常: If Maximized = True Then Me.ScrollBars = 2 Else Me.ScrollBars = 0 End If Me.Field1.SetFocus I managed, in resize event code works just fine: If Maximized = True Then Me.ScrollBars = 2 Else Me.ScrollBars = 0 End If Me.Field1.SetFo ...

如何按比例缩放窗体上的控件以适合窗体?(How to scale controls on a form to fit the form proportionately?)

您可以根据表单的大小设置ResizeEnd或Resize事件的控件的位置和大小。 当表单最小化或非常小时,您需要确保它不会崩溃。 I actually ended up using the table layout panel to arrange everything to proportion with the screen size. It works quite nicely if your controls are laid out in a grid.

当表单最大化时,如何使表单上的所有控件扩展并按比例增加?(How can I get all controls on a form to expand out and increase proportionally in size when form is maximized?)

这对我来说并不太清楚......你可以利用ANCHOR,使LEFT和RIGHT能够使控制向正确的方向发展,并禁用LEFT使其“遍历”整个表格。 当然,对每个控件执行任务,您将获得所需的位置/大小。 无论如何,您可以使用变量手动索引所有控件的所有位置和大小以获得WIDTH和HEIGHT并计算一种索引。 这是一项艰巨的任务,但它可以让您精确控制每个控制位置和高度。 如果你想要保持所有比例(我的意思是,改变他们的FONT大小)的redim控件,也许这段代码可以帮助你: http : //www.code ...

相关文章

更多

最新问答

更多
  • Haml + ActionMailer - Rails?(Haml + ActionMailer - Rails?)
  • 将数据从div标签传递到javascript函数[关闭](Pass data from div tags to javascript function [closed])
  • 如何使用imaplib创建电子邮件并将其发送到特定邮箱(How to create an email and send it to specific mailbox with imaplib)
  • Ruby - 使用`require`命令(Ruby - working with `require` command)
  • 用ng值检索时,在md-input-container中隐藏输入文本字段的值(label hiding input text field value in md-input-container when retrieving with ng-value)
  • 以编程方式将字符串宽度值插入sprintf()(Programmatically insert string width value into sprintf())
  • Matplotlib计算给定字符串的轴坐标范围(Matplotlib Calculate Axis Coordinate Extents Given String)
  • 在同一个流连接上返回多个结果以实现HTML5 Server Sent Events(Returning multiple results on the same stream connection to implement HTML5 Server Sent Events)
  • 限制对特定URL的访问(Apache Tomcat)(Restrict access to specific URL (Apache Tomcat))
  • R中的时间序列与ggplot2(Time Series in R with ggplot2)
  • 自动URL参数编码失败(Automatic URL Parameter Encoding Failing)
  • 是否有任何关于JRuby + Clojure集成的开源示例?(Are there any good open source examples of JRuby + Clojure integration?)
  • ActiveX被认为是旧的/过时的标准吗?(Is ActiveX considered old/outdated by todays standards?)
  • SQL Server中的XML查询(XML Query within SQL Server)
  • PL / SQL:在更新尝试时,删除导致unique_violation异常的行(PL/SQL: on update attempt, delete row which causes unique_violation exception)
  • webpack css-loader localIdent名称哈希长度(webpack css-loader localIdent name hash length)
  • 基诺数解析器(Keno number parser)
  • R:索引数据框列的名称范围(R: Index data frame columns by ranges of their names)
  • 限制ASP .net和Javascript中的多个事件(Restrict multiple events in ASP .net & Javascript)
  • 更改行时SQL查询不更新表(SQL query not updating table when row is changed)
  • JavaScript,document.getElementById不从窗体中抓取?(JavaScript, document.getElementById not grabbing from form?)
  • h2数据库上的Mybatis无法插入数据(Mybatis on h2 database can't insert data)
  • KeyboardWillHideNotification未在iOS 9中触发(KeyboardWillHideNotification not firing in iOS 9)
  • jQuery UI Droppable - 如何实际更改HTML?(jQuery UI Droppable - How to actually change the HTML?)
  • 无法将APK安装到root设备中(Can't install APK into rooted device)
  • 在滚动浏览器时,使jQuery UI对话框不改变它的位置(相对于浏览器)(make jQuery UI dialog not change it's position (relative to the browser) when scrolling browser)
  • 我们可以在NativeScript中使用nedb吗?(Can we use nedb with NativeScript?)
  • 使用CancellationToken的竞争条件,其中CancellationTokenSource仅在主线程上被取消(Race condition with CancellationToken where CancellationTokenSource is only cancelled on the main thread)
  • 使用Framework7从JS更新HTML视图中的数据(Update data in HTML view from JS using Framework7)
  • sql server:选择一个外键为NULL的字段(sql server: select a NULL field that is foreign key)