1
在試圖創建一個圓角矩形的過程中,但決定從一些簡單的事情開始,在這種情況下是一個橢圓。不幸的是,當我將自定義控件拖放到Fprm1.cs [設計]上並嘗試調整其大小時,實際橢圓沒有任何反應。只有當我進入usercontrol [設計]並調整它的大小時,它纔會改變。如果有人能指出我出錯的地方,我將不勝感激。謝謝。調整用戶控件的大小
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace CustomPbar
{
public partial class Pbar : UserControl
{
GraphicsPath path = new GraphicsPath();
public Pbar()
{
InitializeComponent();
path.AddEllipse(0, 0, this.ClientSize.Width, this.ClientSize.Height);
this.Region = new Region(path);
this.BackColor = SystemColors.ControlDarkDark;
}
private void MyForm_Layout(object sender, System.Windows.Forms.LayoutEventArgs e)
{
if (this.Region != null)
{
this.Region.Dispose();
this.Region = null;
}
path.AddEllipse(0, 0, this.Width, this.Height);
this.Region = new Region(path);
}
}
}
非常感謝。 – 2012-03-13 17:30:48