0
영역 및 그래픽 경로 클래스를 사용하여 동적으로 제거/제거 (취소) 양식 영역동적으로 제거/제거 (제거 취소) C#
영역 및 그래픽 경로 클래스를 사용하여 동적으로 제거/제거 (취소) 양식 영역동적으로 제거/제거 (제거 취소) C#
동적으로 양식의 모양을 변경하려면 양식의 Region
속성을 GraphicsPath
에서 새로 만든 Region
개체로 설정합니다. 당신이 누군가가 답변을 원하는 경우, 귀하의 질문에 당신은 정말 많은 노력을해야합니다 (작업 예)
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace Sample
{
public class ShapedForm : Form
{
Button testbutton;
public ShapedForm()
{
// Create a button.
testbutton = new Button();
testbutton.Location = new Point(10, 10);
testbutton.Size = new Size(50, 50);
testbutton.Text = "Click me!";
testbutton.Click += new EventHandler(this.testbutton_Click);
this.Controls.Add(testbutton);
// Remove the border around the form.
this.FormBorderStyle = FormBorderStyle.None;
// Set the initial shape of the form to an ellipse.
GraphicsPath path = new GraphicsPath();
path.AddEllipse(0, 0, 200, 100);
this.Region = new Region(path);
}
private void testbutton_Click(object sender, EventArgs e)
{
// Change the shape of the form to some other ellipse.
GraphicsPath path = new GraphicsPath();
path.AddEllipse(0, 0, 100, 100);
path.AddEllipse(120, 40, 50, 50);
this.Region = new Region(path);
}
}
}
고마워. 제 생각에는, 일단 제거되면 원래 상태로 롤백 할 수 없습니다. 당신의 대답은 꽤 똑 바르다. –
@Suriyan : 예를 들어,에 하나의 버튼이있는 형태는이 같은 형태의 변경 될 수 있습니다. 너의 대답에 대해 –