Can someone please help me in this, I need to use a trackbar (consider: trackBar1) to change the text of a label (consider: label1) according to the location of the trackbar. For example,
first trackbar location --> label text = Stock
second trackbar location --> label text = Shares
.
.
.
I appreciate your assitence.
Loading
HartoPosted Sep 17, 2008, 4:56 AM
if (trackbar1.Value == 0)
{
label1.Text = "shares";
}
.
.
.
Its easier and less time consuming
HartoPosted Sep 7, 2008, 8:02 PM
AlanPosted Sep 7, 2008, 7:23 PM
It's just a matter of splitting the TrackBar's range up amongst how many cases you've got. For example, with 4 cases:
int range = trackBar1.Maximum - trackBar2.Minimum;
int distance = trackBar1.Value - trackBar1.Minimum;
if (trackBar1.Value <= range/4)
{
{
label1.Text = "Stock";
}
else if (distance > range/4 && distance <= range/2)
{
label1.Text = "Shares";
}
else if (distance > range/2 && distance <= range * 3/4)
{
label1.Text = "Cash";
}
else
{
label1.Text = "Property";
}
HartoPosted Sep 7, 2008, 6:11 PM
AlanPosted Sep 7, 2008, 4:28 PM
Something like this perhaps:
if (trackBar1.Value <= (trackBar1.Minimum + trackBar1.Maximum)/2)
{
label1.Text = "Stock";
}
else
{
label1.Text = "Shares";
}