【发布时间】:2018-05-08 00:01:49
【问题描述】:
我遇到了一个无限循环问题。
我有两个数字上/下控件(高度和宽度输入参数)。当用户更改其中一个控件的值时,我需要缩放另一个以保持高宽比不变。
有没有一种方法可以在不调用 ValueChanged 事件的情况下设置控件的值。我只希望在用户更改值时执行 ValueChanged 事件。
private void FloorLength_ValueChanged(object sender, EventArgs e)
{
if (this.mCurrentDocument.System.SuperTrakSystem.FloorBitmap != null)
{
FloorWidth.Value = FloorLength.Value *
((decimal)this.mCurrentDocument.System.SuperTrakSystem.FloorBitmap.Height /
(decimal)this.mCurrentDocument.System.SuperTrakSystem.FloorBitmap.Width);
}
}
private void FloorWidth_ValueChanged(object sender, EventArgs e)
{
if (this.mCurrentDocument.System.SuperTrakSystem.FloorBitmap != null)
{
FloorLength.Value = FloorWidth.Value *
((decimal)this.mCurrentDocument.System.SuperTrakSystem.FloorBitmap.Width /
(decimal)this.mCurrentDocument.System.SuperTrakSystem.FloorBitmap.Height);
}
}
【问题讨论】:
标签: c# user-controls event-handling