按钮Dock属性 [英] button Dock property

查看:98
本文介绍了按钮Dock属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当更改按钮的停靠属性时,按钮的顺序正在改变,请帮我重新安排订单。

例如我按3按钮1,按钮2,按钮3。

i设置以下属性



when change the dock property of buttons,the order of buttons is changing please help me for re arrange the order.
for example i taken the 3 buttons button 1,button 2,button 3.
i set the following properties

this.button 1.Dock = System.Windows.Forms.DockStyle.Bottom;
 this.button 2.Dock = System.Windows.Forms.DockStyle.Bottom;
 this.button 3.Dock = System.Windows.Forms.DockStyle.Bottom;







以上房产的输出是



按钮3

按钮2

按钮1



但我需要



按钮1

按钮2

按钮3



请帮帮我




the output of the above properties is

button 3
button 2
button 1

but i need as

button 1
button 2
button 3

please help me

推荐答案

你好mk1227,



你只需添加按钮以正确的顺序到容器控件/表单 - 这个,所谓的 z-order (google?)与你在Windows中随处可见的相同。但在你的简单案例中,只需按顺序排序即可。



Z-Order并不难以通过一些经验跟踪你的想法。我不得不承认可能不像我看起来那么容易(我开始使用没有任何Designer的Windows API编程,只是在过去用C ++代码编辑器创建GUI。)但这个概念没有改变。 />


这很简单:以后添加的所有内容都会排在最前面(比如在你的Windows桌面上),每个Dock都推另一个Dock。所以我建议不要多想,而是玩吧。使用一些不同颜色的面板创建一个小应用程序(任何其他控件都可以)并设置不同的对接和不同的z订单



a以后设置z-Order的有用方法(不是通过添加)是使用 SetChildIndex 方法。 http://msdn.microsoft.com/en-us/ library / system.windows.forms.control.controlcollection.setchildindex.aspx [ ^ ]



亲切问候Johannes
Hi mk1227,

You just have to add the Buttons to the container control/Form in the right order - this, so called z-order (google?) is the same you see everywhere in Windows. But in your simple case just order them the other way round.

Z-Order isn't to hard to Keep track of in your head with some experience. I have to admit maybe not so easy as it seems to me (I started Windows API programming without any "Designer", just creating the GUI with C++ code-Editor in the old days.)But the concept didn't change.

It's simple: everything added later comes on top (like on your Windows Desktop), every Dock "pushes" the other Dock's away. So I'd recommend not to think to much but "Play" with it. Create a little app with some different colored panels (any other control will do) and set different Dockings and different z-Orders

a useful method to set the z-Order later (not through adding) is to use SetChildIndex method. http://msdn.microsoft.com/en-us/library/system.windows.forms.control.controlcollection.setchildindex.aspx[^]

Kind regards Johannes


Hello Friend .....你必须使用Docking属性和TableLayoutPanel并将All Button放入TableLayoutPanel

使用它并享受







或者您可以使用下面的代码.....





Hello Friend.....You have to use Docking property along with TableLayoutPanel and place All Button into the TableLayoutPanel
use it and enjoy



or you may use belowing code.....


this.Controls.SetChildIndex(textBox1, 2);
this.Controls.SetChildIndex(textBox2, 1);
this.Controls.SetChildIndex(textBox3, 0);
this.textBox1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.textBox2.Dock = System.Windows.Forms.DockStyle.Bottom;
this.textBox3.Dock = System.Windows.Forms.DockStyle.Bottom;


这篇关于按钮Dock属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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