Forum > Designer

any component for spinning through a set?


If I want user to be able to scroll through a set of values and pick one, which component, other than menu, could do this job? Spin Edit can only scroll with interval, but I need interval to be a power of 2. Like spinning through set of values 2,4,8,16 etc.

furious programming:
You can use standard SpinEdit control and change its behavior by overriding the SetValue method to control how the value should change. And, of course, methods like SetMinValue and SetMaxValue and other should also be overriden.

Drop a TEdit and a TUpDown on the form. Do not link them, i.e. do not set the UpDown's Associate to the edit control so that the text displayed by the edit is not overridden by the UpDown steps. Then write an event handler for the UpDown's OnClick:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses  math; procedure TForm1.UpDown1Click(Sender: TObject; Button: TUDBtnType);var  ud: TUpDown;begin  if Sender is TUpDown then  begin    ud := TUpDown(Sender);    Edit1.Text := FloatToStr(IntPower(2, ud.Position));  end;end;

overriding components methods - that would be some furious programming! I will get there one day. I was thinking something along WP's example, up/down and a label. In the end I went with listBox. Looks ugly as sin, but it was quick.

You could also use a combobox and load the values of set into it.

To achieve spinning behavior the selected index of combobox would be set to last item when up arrow is pressed from first item or first item would be selected when down arrow is pressed from last item.


[0] Message Index

Go to full version