private void rb_Click(object sender, EventArgs e)
{
for (int i = 0; i < list.Count; i++)
{
RadioButton rb = new RadioButton();
// rb.Text = list.ToList()[i].Card_Type_Name.ToString();
string GetImage = (System.Environment.CurrentDirectory);
GetImage = GetImage.Substring(0, GetImage.Length - GetImage.StartsWith("FileUploads").ToString().Length - 4);
GetImage += "FileUploads\\CardType" + list.ToList()[i].Image.Substring(list.ToList()[i].Image.LastIndexOf('\\'));
rb.Image = Image.FromFile(GetImage);
rb.Height = 30;
rb.Width = 30;
rb.Tag = list.ToList()[i].Card_Type_ID;
rb.Click+=new EventHandler(rb_Click);
tableLayoutPanel1.Controls.Add(rb);
}
}
}
private void rb_Click(object sender, EventArgs e)
{
RadioButton rb1 = (RadioButton)sender;
MessageBox.Show(rb1.Tag.ToString());
}
{
for (int i = 0; i < list.Count; i++)
{
RadioButton rb = new RadioButton();
// rb.Text = list.ToList()[i].Card_Type_Name.ToString();
string GetImage = (System.Environment.CurrentDirectory);
GetImage = GetImage.Substring(0, GetImage.Length - GetImage.StartsWith("FileUploads").ToString().Length - 4);
GetImage += "FileUploads\\CardType" + list.ToList()[i].Image.Substring(list.ToList()[i].Image.LastIndexOf('\\'));
rb.Image = Image.FromFile(GetImage);
rb.Height = 30;
rb.Width = 30;
rb.Tag = list.ToList()[i].Card_Type_ID;
rb.Click+=new EventHandler(rb_Click);
tableLayoutPanel1.Controls.Add(rb);
}
}
}
private void rb_Click(object sender, EventArgs e)
{
RadioButton rb1 = (RadioButton)sender;
MessageBox.Show(rb1.Tag.ToString());
}
No comments:
Post a Comment