Advertisement
Guest User

Untitled

a guest
Sep 18th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. progressbar1.value=control.location.x/y
  2.  
  3. 'Using The Click or MouseDown or any Mouse Event
  4.  
  5. Dim Value As Integer= Me.PointToClient(MousePosition).X-Progressbar.Bounds.X
  6.  
  7. Progressbar.value= Value
  8.  
  9. private void progressBar1_Click(object sender, EventArgs e)
  10. {
  11. // Get mouse position(x) minus the width of the progressbar (so beginning of the progressbar is mousepos = 0 //
  12. float absoluteMouse = (PointToClient(MousePosition).X - progressBar1.Bounds.X);
  13. // Calculate the factor for converting the position (progbarWidth/100) //
  14. float calcFactor = progressBar1.Width / (float)100;
  15. // In the end convert the absolute mouse value to a relative mouse value by dividing the absolute mouse by the calcfactor //
  16. float relativeMouse = absoluteMouse / calcFactor;
  17.  
  18. // Set the calculated relative value to the progressbar //
  19. progressBar1.Value = Convert.ToInt32(relativeMouse);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement