开发者

c# save trackbar.value

I'm trying to save a TrackBar value to a variable but can't manage to do it since the value changed all the time.

void Volu开发者_如何学JAVAmeBarScroll(object sender, System.EventArgs e)
    {

    int a = VolumeBar.Value;

     }

Is there any way of keeping a value?.


If you need to set value instantly - use ValueChanged event.
If you need to set value only once after finish changing - use MouseCaptureChanged event.

Scroll event - it's behaviour event.

Occurs when either a mouse or keyboard action moves the scroll box.

So, probably you need:

    int trackValue = 0;
    private void trackBar1_MouseCaptureChanged(object sender, EventArgs e)
    {
        trackValue = this.trackBar1.Value;
    }

Also, you are trying to save value to a local variable inside of event handler, if you need to use it outside of event handler, you need to define variable outside of the handler.


you should take a look to this blogs...

http://www.daniweb.com/software-development/csharp/threads/348366

http://en.csharp-online.net/TrackBar

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜