UserControl1
private string lastName;
private string nnovo;
public string LastName
{
get { return lastName; }
set
{
lastName = value;
label2.Text = value;
}
}
public string Nnovo {
get { return nnovo; }
set {
nnovo = value;
label1.Text = value;}
}
Form
Button btn = (Button)sender;
SqlCommand cm = new SqlCommand("SELECT tblCategory.Categoryname, tblProduct.Productname,tblProduct.Sinopse FROM tblCategory INNER JOIN tblProduct ON tblCategory.Categoryid = tblProduct.Categoryid where tblCategory.Categoryname= '" + btn.Text + "'", cn);
try
{
SqlDataReader dr = cm.ExecuteReader();
flowLayoutPanel2.Controls.Clear();
flowLayoutPanel2.Update();
while (dr.Read())
{
UserControl1 user = new UserControl1();
user.Nnovo = (string)dr["Productname"].ToString();//Adiciona os valores do database na label1 do usercontrol
user.LastName = (string)dr["Sinopse"].ToString(); //Adiciona os valores do database na label1 do usercontrol
flowLayoutPanel2.Controls.Add(user);//Carrega usercontrol1 no flowlayoutpanel
flowLayoutPanel2.Update();
} dr.Close();
}
With the above code I can show each product name and database description in the label of each usercontrol. How to display the database image for each usercontrol's picturebox?