C#中怎样设置trackbar每次滑动的长度
来源:百度知道 编辑:UC知道 时间:2024/06/17 09:09:10
类定义:
public partial class Form1 : Form
{
private Point lastPoint = Point.Empty;
public Form1()
{
InitializeComponent();
}
private void trackBar1_MouseDown(object sender, MouseEventArgs e)
{
lastPoint.X = e.X;
lastPoint.Y = e.Y;
if (e.X > this.trackBar1.Minimum && e.X < this.trackBar1.Maximum)
this.trackBar1.Value = e.X;
else if (e.X > this.trackBar1.Maximum)
this.trackBar1.Value = this.trackBar1.Maximum;
else
this.trackBar1.Value = this.trackBar1.Minimum;
}
private void trackBar1_MouseUp(object sender, EventArgs e)
{
lastPoint = Point.Empty;
}
private void trackBar1_MouseMove(object sender, MouseEventArgs e)
{
if (!lastPoint.IsEmpty)
{
if (e.X > this.trackBar1.Minimum && e.X < this.trackBar1.Maximum)
this.trackBar1.Value = e.X;
else if (e.X > this.trackBar1.Maximum)