我使用这些参数创建了一个用户控件
private System.Resources.ResourceSet ProjectRes = Магазин.Properties.Resources.ResourceManager.GetResourceSet(new System.Globalization.CultureInfo("en-us"), true, true);
public ButtonPictureBox()
{
InitializeComponent();
}
private void pictureBox1_MouseEnter(object sender, EventArgs e)
{
Bitmap Imagen = (Bitmap)ProjectRes.GetObject((sender as PictureBox).Name.Substring(2) + "1");
if (Imagen != null)
{
(sender as PictureBox).Image = Imagen;
}
}
private void pictureBox1_MouseLeave(object sender, EventArgs e)
{
Bitmap Imagen = (Bitmap)ProjectRes.GetObject((sender as PictureBox).Name.Substring(2) + "2");
if (Imagen != null)
{
(sender as PictureBox).Image = Imagen;
}
}
private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
{
Bitmap Imagen = (Bitmap)ProjectRes.GetObject((sender as PictureBox).Name.Substring(2) + "1");
if (Imagen != null)
{
(sender as PictureBox).Image = Imagen;
}
}
当我在表单中使用它时,我NAME创建的UserControl但该名称似乎没有传递给那些函数,我怎样才能使它继承名称?
答案 0 :(得分:0)
base.Name
是我在找什么。使用它代替(sender as PictureBox).Name
并开始工作