-1

How do I set the trackbar's anchor to start from a specifiec index? My trackbar goes from 0 - 10, and it's in Form1.. in Form1's constructor I want to set the anchor to the right place, which is determend by an object's property:

public EditRectangle(FormRectangle p)
{
    InitializeComponent();
    this.p = p;
    textBox1.Text = p.GetMass().ToString();
    textBox2.Text = p.GetHeight().ToString();
    textBox3.Text = p.GetWidth().ToString();
    // SET TRACKBAR'S INDEX TO THE RIGHT PLACE BY p.GetElasticity()
}

How do I do it?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880

2 Answers2

1

http://msdn.microsoft.com/en-us/library/system.windows.forms.trackbar.value.aspx

Set trackbar.Value to index that you want.

public EditRectangle(FormRectangle p)
{
    InitializeComponent();
    this.p = p;
    textBox1.Text = p.GetMass().ToString();
    textBox2.Text = p.GetHeight().ToString();
    textBox3.Text = p.GetWidth().ToString();
    // SET TRACKBAR'S INDEX TO THE RIGHT PLACE BY p.GetElasticity()
    trackbar.Value = p.GetElasticity();
}
Tom
  • 1,330
  • 11
  • 21
1

The trackbar.Value Gets or sets a numeric value that represents the current position of the scroll box on the track bar. In your case between 0 - 10. That is if you used the trackbar.SetRange method right.

RTB
  • 5,773
  • 7
  • 33
  • 50