Set gh_slider value

Hi all,

I am building c# component that automatically generates gh_numbersliders and set max,min and current value. I managed to set the max and min value using the code below, but i cannot figure out how to set the current value.

  var ghSlider = new Grasshopper.Kernel.Special.GH_NumberSlider();
  gid = ghSlider.InstanceGuid;
  gids.Add(gid, new GH_Path(i));
  ghSlider.CreateAttributes();
  ghSlider.SetSliderValue((decimal) 22);
  //ghSlider.TrySetSliderValue((decimal) 22);
  //ghSlider.Slider.Value = (decimal) 22; 
  ghSlider.Slider.DecimalPlaces = 0;
  ghSlider.Slider.Maximum = (decimal) max;
  ghSlider.Slider.Minimum = (decimal) min;

Tried slider.value, SetSliderValue, TrySetSliderValue, but no matter what i do, i got sliders with the handle way off the component, which means set value didn’t work. Any idea? Thanks in advance.

W

figured this out by myself, but for those who might have the same question, it was just matter of order. You set the max and min first then you set the current value.

W