Question

I have make a playbar for my new MP3 player but I have a problem as shown in attachement and this is my simple code :

 public void setpercent(int percent)
     {
         pic1.Width = pic2.Width / 100 * percent;
         pic3.Left = pic1.Width - ( pic3.Width /2); 

     }

I thought to use Graphics but I can't move it after. and the method of ".Parent" doesn't work in this case.

enter image description here

Was it helpful?

Solution

In the Load() event of your Form, modify the Region() property of pic3 so that it becomes circular instead of rectangular. This can be done by construction a GraphicsPath and adding an Ellipse to it. If this doesn't line up properly with your image, then manually determine the correct bounding box for the ellipse and use that instead:

    private void Form1_Load(object sender, EventArgs e)
    {
        System.Drawing.Drawing2D.GraphicsPath GP = new System.Drawing.Drawing2D.GraphicsPath();
        GP.AddEllipse(pic3.ClientRectangle);
        pic3.Region = new Region(GP);
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top