0

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();//Adds the values ​​of the database in label1 the usercontrol
                    user.LastName = (string)dr["Sinopse"].ToString(); //Adds the values ​​of the database in label2 the usercontrol

                    flowLayoutPanel2.Controls.Add(user);//Load usercontrol1 in flowlayoutpanel
                    flowLayoutPanel2.Update();

                } dr.Close();           
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.ExitThread();
            }                     
        }

With the above code I can show each "product name" and "description" of the database in the label of each usercontrol. How to show the image of the database for each picturebox usercontrol?

2
Contributors
2
Replies
37
Views
3 Years
Discussion Span
Last Post by Struct.dorlitz
1

Your user control just needs to include a picture box for you to pass the image url to. Or am I missing something?

0

Usercontrol have the picturebox but do not know how to fill it to call the form, any suggestions?.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.