超级奇怪的按钮上加图片的问题
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace PengoodButton
{
public class MyButton : Button
{
private ButtonStyle ButtonStyleValue;
public ButtonStyle SetButtonStyle
{
get { return ButtonStyleValue; }
set { ButtonStyleValue = value; }
}
public enum ButtonStyle
{
submit, cancel, del, add, edit, refresh
}
/// <summary>
/// 重绘控件
/// </summary>
/// <param name="pevent"></param>
protected override void OnPaint(PaintEventArgs e)
{
this.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.Padding = new System.Windows.Forms.Padding(10, 0, 0, 0);
this.Size = new System.Drawing.Size(85, 30);
switch (ButtonStyleValue)
{
case ButtonStyle.add:
this.Text = "添加";
this.Image = PengoodButton.ResourceButton.add;
break;
case ButtonStyle.cancel:
this.Text = "取消";
break;
case ButtonStyle.del:
this.Text = "删除";
this.Image = PengoodButton.ResourceButton.del;
break;
default:
this.Text = "错误";
break;
}
base.OnPaint(e);
}
}
}
出现的问题:
如果选择到是取消,那么一点问题也没有,如果选择的是删除按钮,按钮上的图片也能正常显示,但CPU占得很高,像是图片在死循环一样,问题就出现在
this.Image = PengoodButton.ResourceButton.del;
这句上面,何解呢?
备注:资源文件正常,图片存在
如果不使用资源文件来放图片,那么编译成dll后,图片放哪里去?