的UserControl1
private string lastName;
public string LastName
{
get { return lastName; }
set
{
lastName = value;
label1.Text = value;
}
}
表格
public void Gerar_codigo_Click(object sender, EventArgs e)
{
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
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();
}
}
在我的UserControl
我label1
和picturebox1
。
我设置了Label
但是如何设置PictureBox
以表单形式加载图片?
帮帮我?
答案 0 :(得分:0)
将图像读取到字节数组,创建它的位图并设置为picturebox1的图像。