473,408 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

learning exercise... help?

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

Jul 26 '07 #1
3 1333
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

"S Moran" <s@moran.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
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

Jul 26 '07 #2
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 Moran" <s@moran.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
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

Jul 26 '07 #3
perfect, thank you

"James" <mi*******@gmail.comwrote in message
news:ur**************@TK2MSFTNGP06.phx.gbl...
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 Moran" <s@moran.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>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

Jul 26 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: James | last post by:
I'm looking for some advice in teaching myself how to program. I just finished reading O'Reilly's Practical C++ Programing. I can do anything that was convered in the book very comfortably...
3
by: Sean McCourt | last post by:
Hi I am doing a JavaScript course and learning from the recommed book (JavaScript 3rd Edition by Don Gosslin) Below is one of the exercises from the book. I get this error message when I try to...
1
by: Brent Ritchie | last post by:
Hello, I put up a small web application called SVG Creator, I'm developing it as a learning exercise. The url is: http://www3.sympatico.ca/brentritchie/. So far development is going well, but;...
5
by: Richard Gromstein | last post by:
Hello, I have an exercise that I need to finish very soon and I really need help understanding what to do and how exactly to do it. I am working on reading the chapter right now and working on it...
5
by: arnuld | last post by:
this is a programme that counts the "lengths" of each word and then prints that many of stars(*) on the output . it is a modified form of K&R2 exercise 1-13. the programme runs without any...
24
by: Michael Tobis | last post by:
I want a list of all ordered permutations of a given length of a set of tokens. Each token is a single character, and for convenience, they are passed as a string in ascending ASCII order. For...
4
by: DjShifta | last post by:
Ok this really shouldn't be that hard...but I can not figure out whats' wrong for the life of me. I am brand new to "coding" and have thus far just built basic sites with Dreamweaver, but am going...
4
by: neptundancer | last post by:
Hi, to extend my skills, I am learning python. I have written small program which computes math expression like "1+2*sin(y^10)/cos(x*y)" and similar, so far only + - * / ^ sin con tan sqrt are...
4
by: somenath | last post by:
Hi All, I have some questions about the process of learning C language. I see in this groups all expert most of the time quote from C standard. 1) My question is do all of you study the C...
3
by: Speckydodge | last post by:
Hi im learning java through blue j and im having trouble doing an exercise if anyone can help that would be great. the question is: Rewrite the getLot method so it doesn't rely on a lot with a...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.