[英]How to get label value from Picturebox on Picturebox click event
I have tried many ways to read label value from PictureBox when a user clicks PictureBox which is inside of flowLayoutPanel1.当用户单击 flowLayoutPanel1 内部的 PictureBox 时,我尝试了多种方法从 PictureBox 读取 label 值。 enter image description here Anyone help me on this.在此处输入图像描述任何人都可以帮助我。
From the attached image, I want to read price value when the user clicks on the "PictureBox Click Event".从附图中,我想在用户单击“PictureBox Click Event”时读取价格值。
pic.Click += new EventHandler(picture_click);
void picture_click(object sender, EventArgs e) {
if (pic != null) {
pic.BorderStyle = BorderStyle.None;
pic = (PictureBox)sender;
pic.BorderStyle = BorderStyle.Fixed3D;
}
}
foreach (Control c in pic.Controls)
{
if (c.GetType().Name == "Label")
{
if(pic.Controls.IndexOf(c).ToString() == "0")
{
_Prc = c.Text.Replace("Rs.", "");
_Prc = _Prc.Replace("/-", "");
}
else if (pic.Controls.IndexOf(c).ToString() == "1")
{
_Menu = c.Text;
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.