using System; using System.Drawing; using System.Windows.Forms; namespace UserControlClass { public partial class LabPictureControl : UserControl { public LabPictureControl() { InitializeComponent(); } /// /// 添加LabelText属性,可以对labelText进行设置 /// public string LabelText { get { return labText.Text; } set { labText.Text = value; } } /// /// 上面Label的图片图片连接 /// public Image LabelTopImage { get { return labPicture.Image; } set { labPicture.Image = value; } } /// /// 文字位置坐标 /// public Point LabelPoint { get { return labText.Location; } set { labText.Location = value; } } private void labPicture_MouseHover(object sender, EventArgs e) { LabPictureControl lpc = (LabPictureControl)(sender as Label).Parent; lpc.BackColor = Color.FromArgb(0, 151, 186); } private void labPicture_MouseLeave(object sender, EventArgs e) { LabPictureControl lpc = (LabPictureControl)(sender as Label).Parent; lpc.BackColor = Color.FromArgb(19, 46, 53); } private void labText_MouseHover(object sender, EventArgs e) { LabPictureControl lpc = (LabPictureControl)(sender as Label).Parent; lpc.BackColor = Color.FromArgb(0, 151, 186); } private void labText_MouseLeave(object sender, EventArgs e) { LabPictureControl lpc = (LabPictureControl)(sender as Label).Parent; lpc.BackColor = Color.FromArgb(19, 46, 53); } private void LabPictureControl_MouseHover(object sender, EventArgs e) { LabPictureControl lpc = sender as LabPictureControl; lpc.BackColor = Color.FromArgb(0, 151, 186); } private void LabPictureControl_MouseLeave(object sender, EventArgs e) { LabPictureControl lpc = sender as LabPictureControl; lpc.BackColor = Color.FromArgb(19, 46, 53); } } }