日期:2014-05-18  浏览次数:20927 次

怎么固定控件之间距离
比如两个expander,当第一个expander展开时后一个expander根据第一个erpander展开的大小而自动往后一定距离使得两个expander之间的距离固定

------解决方案--------------------
//如果你的是两个button ,可以用下面的代码。
C# code
int difX = button1.Location.X - button2.Location.X;
int difY = button1.Location.Y - button2.Location.Y;
MessageBox.Show("X:"+difX.ToString()+"\tY:"+difY.ToString());

------解决方案--------------------
可以使用 TableLayoutPanel 和 FlowLayoutPanel 来管理控件的布局。