learning exercise... help?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • S Moran

    #1

    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

  • Kevin Spencer

    #2
    Re: learning exercise... help?

    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:


    "S Moran" <s@moran.comwro te in message
    news:%23PZ$fz4z HHA.5476@TK2MSF TNGP03.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
    >

    Comment

    • James

      #3
      Re: learning exercise... help?

      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.comwro te in message
      news:%23PZ$fz4z HHA.5476@TK2MSF TNGP03.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
      >

      Comment

      • S Moran

        #4
        Re: learning exercise... help?

        perfect, thank you



        "James" <minorkeys@gmai l.comwrote in message
        news:urLCUi5zHH A.2484@TK2MSFTN GP06.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.comwro te in message
        news:%23PZ$fz4z HHA.5476@TK2MSF TNGP03.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
        >>
        >
        >

        Comment

        Working...