   [.net] C# - Help to build a custom Slider!!!
  Hi, i'm trying to build a custom Slider component for a long time but with no success, i've got serious problems to set the position of the slider and get it's values and raise an event to show that value. I'm using a PictureBox to set a texture (Skin) to the slider, like WinAMP, with this it's ok, the problem is to set and get the position.Please, can someone help me please, i'm new in C#.Forgive me my bad english.Cheers,ultraMAX   
  hehe, I just wrote a slidebar at work. Unfortunately it's in &#106avascript not C#.   ;  Forgive me capn_midnight, but i'n newbie in C#, i can already move the PictureBox inside the form where i'm building the component, but like a said the problem now is i don't know how can i set or get its position, and then raise a event to tell to other form (example: textbox) its value, can you help me please?Thanks for the reply,UltraMAX   ;  to start, you should have your SlideBar inherit from the System.Windows.Forms.UserControl class. When you create the class, use the "add new..." dialog so that you can select New User Control. It will start a template for you and open the control in the form designer so you can start building it.There are really only three events that a slidebar will have to handle: OnMouseDown, OnMouseMove, and OnMouseUp. These are all declared in your custom user control class in much the same wayprotected override OnMouseDown(MouseEventArgs e){   base.OnMouseDown(e);}just declare one for each of the three events.OnMouseDown should do two things: it should check to see if the user has clicked inside the rectangle that is the handle of the slide bar, and if it has, it should store the X or Y coordinate of the mouse (X if this slidebar runs horizontally, Y if it runs vertically). I'm going to assume a horizontal slide bar, if you want vertical than you exchange X for Y and Width for Height in any of my explainations.OnMouseMove should do one thing: if the drag state is set, it should update the location of the handle based on how far the mouse has moved since the last time the method was called. At the end of the method.OnMouseUp should do two things: it should finalize the setting of the value of the slidebar and it should reset the dragging state to off.you should also override the OnPaint method so that you can paint the slot that goes down the middle of the control and the handle that indicates the value.each of the 3 mouse events should cause the control to "invalidate" so that they will paint the control and show the updated value.getting and setting the value... that's up to you. You need to define what the value is, and you need to update that value whenever those mouse events occurs, and then you need to return that value when you call the GetValue method.   ;  or, you could use a System.Windows.Forms.TrackBar control... no need to implement one yourself.   ;  Thank you capn_midnight for helping me, i did it, i create a component where the picturebox is the slider who moves along the form component, i had to create some functions to retrieve the the exact position of the picturebox on the component, but i've another problem now, how can i made a MouseUp event for the component? Any ideas, please?If you find any erros on this text, forgive me my english!Thank you for the help,Cheers, UltraMAX.   ;Quote:Original post by UltraMAX2K5Thank you capn_midnight for helping me, i did it, i create a component where the picturebox is the slider who moves along the form component, i had to create some functions to retrieve the the exact position of the picturebox on the component, but i've another problem now, how can i made a MouseUp event for the component? Any ideas, please?If you find any erros on this text, forgive me my english!Thank you for the help,Cheers, UltraMAX.if you are extending the UserControl class, then you mearly override the OnMouseUp method. A brief example:public class SlideBar : System.Windows.Forms.UserControl{    protected override void OnMouseUp(MouseEventArgs e)    {   //the magic goes here    }};  Thank you capn_midnight for the tip, but i can't make it work, can i send you the code for you see what i'm doing wrong, i've done a ValueChanged Event and it works, but i want to make the changes on the MouseUp Event not in this one, this one it's for other "things", can you help me?   ;  Jesus ... forgive me, the "Anonymous Poster" it's me :(   ;  Finally i did, thank you very much capn_midnight for the override tip, after a hard study about how to override an method i finally done it what i was trying to do, thank you.Cheers,UltraMAX.   