質問

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

役に立ちましたか?

解決

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);
    }
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top