- Delete the current designer.cs file
(刪除 .designer.cs 檔) - Right click on the .aspx file and choose Convert to Web Application
(在欲重新產生的程式上按滑鼠右鍵,點選 "轉換成網站應用程式)
2012年3月13日 星期二
Regenerating the Designer.cs File (重新產生 designer.cs)
2010年4月1日 星期四
EventHandler (加掛 Class 的 event 處理函數)
加掛 Class 的 event 處理函數
public CustomColorCheckBox()
{
this.checkColor = this.ForeColor;
this.Paint += new PaintEventHandler(this.PaintHandler);
this.Click += new EventHandler(this.OnClick1);
this.KeyUp += new KeyEventHandler(OnKeypress);
}
public void OnKeypress(object sender, KeyEventArgs e)
{
MessageBox.Show(e.KeyCode.ToString(), "Your input");
}
MessageBox.Show(e.KeyCode.ToString(), "Your input");
}
public void OnClick1(object sender, EventArgs e)
{
MessageBox.Show("Hello C#");
}
private void PaintHandler (object sender, PaintEventArgs pe)
{
if (this.Checked)
{
Point pt = new Point();
if (this.CheckAlign == ContentAlignment.BottomCenter)
{
pt.X = (this.Width / 2) - 4;
pt.Y = this.Height - 11;
}
if (this.CheckAlign == ContentAlignment.BottomLeft)
{
pt.X = 3;
pt.Y = this.Height - 11;
}
if (this.CheckAlign == ContentAlignment.BottomRight)
{
pt.X = this.Width - 11;
pt.Y = this.Height - 11;
}
if (this.CheckAlign == ContentAlignment.MiddleCenter)
{
pt.X = (this.Width / 2) - 4;;
pt.Y = (this.Height / 2) - 4;
}
if (this.CheckAlign == ContentAlignment.MiddleLeft)
{
pt.X = 3;
pt.Y = (this.Height / 2) - 4;
}
if (this.CheckAlign == ContentAlignment.MiddleRight)
{
pt.X = this.Width - 11;
pt.Y = (this.Height / 2) - 4;
}
if (this.CheckAlign == ContentAlignment.TopCenter)
{
pt.X = (this.Width / 2) - 4;
pt.Y = 3;
}
if (this.CheckAlign == ContentAlignment.TopLeft)
{
pt.X = 3;
pt.Y = 3;
}
if (this.CheckAlign == ContentAlignment.TopRight)
{
pt.X = this.Width - 11;
pt.Y = 3;
}
DrawCheck(pe.Graphics, this.checkColor,pt);
}
}
訂閱:
文章 (Atom)