Windows窗体最大大小事件 [英] Windows Form Maximum Size Event

查看:65
本文介绍了Windows窗体最大大小事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友您好,



我在窗口应用程序中工作。表单中有两个组框,每个组框都有一个网格视图。我需要的是当我点击形式的最大按钮然后组合框和组内框中的控件也应该增加并且在形状上相同而没有间隙。

但是当我最大化它的大小时它会增加组盒子但是两者之间有差距。



 私人  void  Form1_Resize( object  sender,EventArgs e)
{
if this .MaximizeBox)
{

groupBox1.Dock = DockStyle.Left;
groupBox2.Dock = DockStyle.Right;
}
}







请告诉我如何解决这个问题?< br $>




预付款

Neetesh

解决方案

< blockquote>而不是使用Dock左侧和Dock右侧,使用Splitter填充表单,并将每个控件停靠在每侧的面板中。

将SplitterWidth属性减少为1,并将IsSplitterFixed设置为true。 br />
然后处理Splitter.Resize事件并将SplitterDistance设置为宽度的一半。 (你也可以在表格加载或显示的事件中这样做。

它比左或右对接更好,它需要一个中心区域用于其他控件。



(您也可以通过在设计器中手动设置控件并正确设置Anchor属性来实现此目的,但是如果使用两个以上的控件,那就太麻烦了)

Hello friends,

I am working in a window Application. There is two group box in form and each group box has a grid view. My need is when I click on Maximum button of form then Both Group box and control inside group box should also increases and fit in form equally without no gap.
But when I am maximize the size it increases group box but there is a gap between two .

private void Form1_Resize(object sender, EventArgs e)
       {
           if (this.MaximizeBox)
           {

               groupBox1.Dock = DockStyle.Left;
               groupBox2.Dock = DockStyle.Right;
           }
       }




Please tell me how to solve this?


Thanks in Advance
Neetesh

解决方案

Instead of using Dock left and Dock right, fill your form with a Splitter, and dock each control in a panel each side.
Reduce the SplitterWidth property to 1, and set IsSplitterFixed to true.
Then handle the Splitter.Resize Event and set the SplitterDistance to half the width. (You will also want to do this in the form Load or Shown event as well.
It will work a lot better than docking left or right, which expects a centre area for other controls.

(You can also do this by setting the controls in place manually in the designer and setting the Anchor properties correctly, but that gets kinda messy to work out with more than two controls)


这篇关于Windows窗体最大大小事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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