Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How to set a slider's orientation programmatically?

Solved!
Go to solution

Hello out there,

I need to change  a slider's orientation at run-time. However, there is no property to do this - in design mode you click on a separate 'link' which magically arrives at changing it.

 

Can this magic be made public?

Thanks for any hints and best regards

Helmut Giese

0 Kudos
Message 1 of 5
(3,845 Views)

What you may want to try is having 2 controls, 1 in each orientation, and show 1 while hiding the other.  You can also move them off screen but hiding them is probably easier.  Of course, you would need some logic added to know which one to read/update or you could just read and write to both.  I've used this method to overlay text and graphics controls on top of each other in the same display area of a form.  I would switch between the two depending on what I needed to do.  You couldn't tell the difference in appearance.

 

Tom

0 Kudos
Message 2 of 5
(3,842 Views)

Hi Tom,

hey, a sneaky solution.:)

In my context it looks like quite some work though. I am implementing kind of a mini VS environment, where the end user will select GUI elements from a restricted set of components, configure them as needed, etc. and in the end have his 'design' run like a 'real' programmer had been working with Visual Studio.

 

So I would have to handle this show/hide business at (user) design time, too, which looks a bit complicated.

 

But if all else fails, I could try to go this route. Still, since it can be done from within Visual Studio, there should be a way to do it programmatically.

Thanks for an interesting idea.

Helmut - keeping fingers crossed - Giese

0 Kudos
Message 3 of 5
(3,830 Views)
Solution
Accepted by topic author hgiese

hello hgiese - 

 

The main part of the 'magic' that is happening is in the ScalePosition property.  You could mimic the "Invert Orientation" action taken on a vertical slide with the following code:

 

int newWidth = slide1.Height;
int newHeight = slide1.Width;
slide1.ScalePosition = NumericScalePosition.Bottom;
slide1.Height = newHeight;
slide1.Width = newWidth;

 

NickB

National Instruments 

0 Kudos
Message 4 of 5
(3,824 Views)

Hi Nick,

great - exactly what I needed.

 

In fact, I had tried the ScalePosition property but the result just didn't look at all 'right' - but I had not considered exchanging the values for width and height.

 

Many thanks and have nice weekend.

Helmut Giese

0 Kudos
Message 5 of 5
(3,821 Views)