gpt4 book ai didi

c# - 按下键盘键时如何更改 TrackBar 控件操作?

转载 作者:行者123 更新时间:2023-11-30 20:57:30 27 4
gpt4 key购买 nike

TrackBar 控件的变化方向与它在被更改时应该的方向相反:向上翻页/向下翻页/向上箭头/向下箭头。

这里有详细介绍: Why does the Trackbar value decrease on arrow up/PgUp?

有没有办法修复/逆转这种行为?

最佳答案

嗯……我以前从没注意到。这是我对@Hans 的建议的尝试:

public class MyTrackBar : TrackBar
{

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
switch (keyData)
{
case Keys.Up:
this.Value = Math.Min(this.Value + this.SmallChange, this.Maximum);
return true;

case Keys.Down:
this.Value = Math.Max(this.Value - this.SmallChange, this.Minimum);
return true;

case Keys.PageUp:
this.Value = Math.Min(this.Value + this.LargeChange, this.Maximum);
return true;

case Keys.PageDown:
this.Value = Math.Max(this.Value - this.LargeChange, this.Minimum);
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}

}

关于c# - 按下键盘键时如何更改 TrackBar 控件操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16801083/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com