Results 1 to 7 of 7

Thread: [2008] - ProgressBar Click Position

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2008
    Posts
    284

    [2008] - ProgressBar Click Position

    How can I find the click position of the mouse inside a progressbar?

    so basically the left side of the progressbar = 0 and the right side = 100

    any way of how I can do this?
    I am still very new to VB.NET, so I have MANY questions

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: [2008] - ProgressBar Click Position

    Is it your intention to set the Value of the ProgressBar based on where the user clicks? If so then you should be using a TrackBar, not a ProgressBar.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2008
    Posts
    284

    Re: [2008] - ProgressBar Click Position

    I want to show the progress of an audio file playing, which works. I then want to allow the user to be able to click on a certain area of the progressbar, then be taken to that position of the audio file.
    I am still very new to VB.NET, so I have MANY questions

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: [2008] - ProgressBar Click Position

    You could handle the MouseClick event, which does provide location information, but you should be using a TrackBar, which is built for this purpose.

  5. #5
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Re: [2008] - ProgressBar Click Position

    Personally i'd code my own control for something like that, as I assume you are wanting the progress bar for its neat appearance. just use a picturebox, draw to it yourself, if progressbar doesn't tell you location upon click(which it probably does, if not on click, it should on mousedown), i can assure you that picturebox definitely does...

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2008
    Posts
    284

    Re: [2008] - ProgressBar Click Position

    so how would I do a pictureBox progressbar?
    I am still very new to VB.NET, so I have MANY questions

  7. #7
    New Member
    Join Date
    Aug 2008
    Posts
    1

    Re: [2008] - ProgressBar Click Position

    Got here via google trying to figure out how to do this, but I got it working in a minute anyways. So, I suppose I'll post the code up for anyone else that ends up here through google and such.

    Code:
    Private Sub prgsbar_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles prgsbar.MouseDown
          prgsbar.Value = CInt((e.Location.X / prgsbar.Size.Width) * 100)
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width