?
Solved

Trackbar problem

Posted on 2006-04-10
4
Medium Priority
?
580 Views
Last Modified: 2008-01-09
I want to handle Trackbar control ValueChanged event, but only when scrolling stopped. All time while user drags the handle, I need to ignore this and handle new value only when dragging finished. Is it possible with Trackbar control? If this is impossible, what other control can I use to get the same functionality?
I have API solution for this: handle WM_HSCROLL messages in the parent form, but I prefer .NET solution.
0
Comment
Question by:AlexFM
  • 2
  • 2
4 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 16417383
You could skip using the ValueChanged event altogether:

  private int _currentValue = -1;
  private void trackBar1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
  {
    _currentValue = ((TrackBar)sender).Value;
  }

  private void trackBar1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
  {

    int val = ((TrackBar)sender).Value;

    if (val != _currentValue)
      MessageBox.Show("New Value=" + val);
  }

Bob
0
 
LVL 48

Author Comment

by:AlexFM
ID: 16418239
Thanks. This may work for mouse but it is possible to move handle using keyboard, this also requires handling.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16418361
You can handle the keyboard changes like this:

  private void trackBar1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
  {
    switch (e.KeyCode)
    {
      case Keys.Right:
      case Keys.Left:
      case Keys.PageUp:
      case Keys.PageDown:
      case Keys.Home:
      case Keys.End:
        MessageBox.Show("New Value=" + ((TrackBar)sender).Value);
        break;

      default:
        break;

    }

Bob
0
 
LVL 48

Author Comment

by:AlexFM
ID: 16423968
Well, I think I will prefer API solution.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month16 days, 18 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question