Reputation: 11
I'm currently working on a quite simple Windows Form program and I currently have a small issue regarding trackbars.
It's kind of a stats distributor for characters so I have 6 trackbars which should allow the user to distribute a set amount of point to each stats of the said character. They have a common maximum of points they can distribute so I check and confirm when they reach the max ammmount of points they could distribute but here's the problem, I don't know how to prevent the cursor to ONLY go up. I know I can disable the trackbars completely but then the user can't adjust the amounts of points even if he only wanted to lower a value to adjust it. How can I stop them from adding point without disabling the trackbars completely?
Upvotes: 1
Views: 872
Reputation: 63377
You can handle the ValueChanged
event handler and do something like this:
int lastValue;
//ValueChanged event handler for your trackBar1
private void trackBar1_ValueChanged(object sender, EventArgs e){
if (trackBar1.Value < lastValue) trackBar1.Value = lastValue;
lastValue = trackBar1.Value;
}
Upvotes: 0