learning exercise... help?

S

S Moran

c# 2.0

windows form with a slider control. trying to make the form opacity change
as the slider is moved. problem (i think) is that the opacity property takes
a percent-based number. so... 50% if you do it at design time, but .5 if you
do it via code... but the slider increments in whole numbers so i guess i
have to convert somewhow? an example would be appreciated

thank you
 
K

Kevin Spencer

The slider has a maximum value which is an integer, and you can set it to
whatever you want. So, to create a simple example, if you're talking
percentages or decimal numbers, you could set a value of 100 for the maximum
value of the slider. Each unit would evaluate to 1 percent (or 1/100) of the
total, or in decimal, 0.01. So, if you set the slider to 25, that's 25% or
0.25.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 
J

James

Incredibly quick/dirty with a trackBar control with a max value of 100.

Single x;
Single y = trackBar1.Value;
x = (100 - y) / 100;
this.Opacity = x;
 
S

S Moran

perfect, thank you



James said:
Incredibly quick/dirty with a trackBar control with a max value of 100.

Single x;
Single y = trackBar1.Value;
x = (100 - y) / 100;
this.Opacity = x;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top