我动态显示一些图像,当我用鼠标悬停时,我想显示一个文本框,如果有的话,它将显示在所有图像或其中的一些图像上。
这是我动态分配图片的方式:
var picture = new PictureBox
{
Name = "pictureBox" + contor,
Size = new Size(72, 72),
Location = new Point(x, y),
Image = Image.FromFile("C://Users//radul//OneDrive//Desktop//Pictures Lic//rf 72x72.png"),
};
x += 100;
y = (y + 100) % this.Size.Height;
picture.MouseDown += new MouseEventHandler(picture_MouseDown);
picture.MouseMove += new MouseEventHandler(picture_MouseMove);
picture.MouseUp += new MouseEventHandler(picture_MouseUp);
picture.MouseHover += new EventHandler(picture_MouseHover);
picture.MouseLeave += new EventHandler(picture_MouseLeave);
this.Controls.Add(picture);
并显示文本框:
private void picture_MouseHover(object sender, EventArgs e){
tBox.Height = 100;
tBox.Width = 400;
tBox.Multiline = true;
tBox.BringToFront();
tBox.Text = detalii;
tBox.Top = picBox.Top + 20;
tBox.Left = picBox.Right + 20;
this.Controls.Add(tBox);
}
Output,这是我的程序显示的内容,我希望该文本框位于该图像上方。