在MDI表单上设置运行时控件的位置和大小时出现问题 [英] Problem in setting location and size of a control in runtime on a MDI form

查看:102
本文介绍了在MDI表单上设置运行时控件的位置和大小时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在使用Windows应用程序。我的表格是MDI表格。在我的表格中,我有两个面板,两个按钮,如TOTAL和CUSTOMER。因此,当我点击TOTAL按钮时,应显示总面板,何时分别显示客户面板和CUSTOMER。我在设计模式下将sqiz dt面板缩小为小尺寸,为此我已用代码编写,

Hi,

I am working on windows application. My form is MDI form. In my form I have two panel,two button like "TOTAL" and "CUSTOMER". So when i am clicking the TOTAL button the total panel should display and when to CUSTOMER the customer panel should display respectively. I have sqiz dt panel into small size in design mode and For that i have written in code,

private void btnTotal_Click(object sender, EventArgs e)
{
   panelTotal.Visible = true;
   panelTotal.Location = new Point(8, 449);
   panelTotal.Size = new Size(634, 118);
}



所以我的问题是在我的表格作为MDI之前它完美地工作但是在制作MDI之后,它不起作用。如果我将设置为设计模式,那就好了,但如果在代码中提到hv它不起作用。它搞砸了我的设计。所以请帮我解决这个问题。我很感激你。



谢谢。


So my problem is before doing my form as MDI it was working perfectly but after making MDI, it's not working. If i'll set in design mode it's Ok but if hv mentioned in code its not working. It messed up my design. So please help me to solve this problem. I'll be grateful to you.

Thanks.

推荐答案

有一些表格的属性在窗体上设置控件的位置。甚至Control都有 Control.Dock [ ^ ]& Control.Anchor [ ^ ]用于设置控件位置。



尺寸&您添加硬编码的位置将无法在每个系统上运行,您可能知道每个系统可能具有不同的分辨率。如果用户更改表单大小怎么办?



有一些控件属性可以帮助您设置控件。

< a href =http://msdn.microsoft.com/en-us/library/system.windows.forms.control.top.aspx> Control.Top [ ^ ]

Control.Left [< a href =http://msdn.microsoft.com/en-us/library/system.windows.forms.control.left(v=vs.71).aspx\"target =_ blanktitle =New Window > ^ ]

控制。右 [ ^ ]



为什么不考虑MDI表单的 Control.Height [ ^ ]& Control.Width [< a href =http://msdn.microsoft.com/en-us/library/system.windows.forms.control.width(v=vs.71).aspx\"target =_ blanktitle =New Window > ^ ]用于设置面板位置的属性。看一下这里。 [ ^ ]即使你可以使用Left& MDI表单的正确属性,用于设置面板的位置,看看这里。 [ ^ ]



有一些与您的问题相关的答案。



1)http://stackoverflow.com/questions/2414377/change-the-size- of-the-panel-dynamic [ ^ ]

2)http ://stackoverflow.com/questions/968728/update-label-location-in-c [ ^ ]

3)http://www.java2s.com/Tutorial/CSharp/0460__GUI-Windows-Forms/ControlSizeandLocationDynamic.htm [ ^ ]



希望这会有所帮助。
There are some properties of form for setting up the location of the controls on form. Even Control has the Control.Dock[^] & Control.Anchor[^] for setting up the controls position.

Size & Location which you added hard coded will not work on every system, As you might know every system might have different resolution. What if User Change the size of the form?

There are some property of controls which help you to set up the controls.
Control.Top[^]
Control.Left[^]
Control.Right[^]

Why don't you consider the MDI form's Control.Height[^] & Control.Width[^] property for setting up the location of the panel. Have a look here.[^] Even you can use Left & Right property of MDI form to set up the location of the panel, Have a look here.[^]

There are some Answer related to your issue.

1) http://stackoverflow.com/questions/2414377/change-the-size-of-the-panel-dynamically[^]
2) http://stackoverflow.com/questions/968728/update-label-location-in-c[^]
3) http://www.java2s.com/Tutorial/CSharp/0460__GUI-Windows-Forms/ControlSizeandLocationDynamic.htm[^]

Hope this helps.


这篇关于在MDI表单上设置运行时控件的位置和大小时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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