Click here to Skip to main content
15,900,108 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Good day
Could you please help, I am using EF 4.0 windows application c#. I am battling to display imagebackground on dynamically loaded button. your help will be much appreciated.
1. I have a table TblProduct with a column "Image" and datatype = Image
2. my code
int i = 1;

foreach (TabPage tp in tabControl1.TabPages)
{

ObjectQuery<tblproduct> listProduct = new ObjectQuery<tblproduct>("SELECT VALUE P FROM TblProducts AS P WHERE P.ProductType = " + i.ToString(), afNewObject);

FlowLayoutPanel flp = new FlowLayoutPanel();
flp.Dock = DockStyle.Fill;

foreach (TblProduct tprod in listProduct)
{
Button b = new Button();
b.Size = new Size(100, 100);
b.Text = tprod.Description;

b.BackgroundImage = tprod.Image; // error line

b.Tag = tprod;

b.Click += new EventHandler(UpdateProductList);

flp.Controls.Add(b);
}

tp.Controls.Add(flp);
i++;
Posted
Comments
Wendelius 6-Sep-15 12:52pm    
Don't repost. If you need to make modifications to the question, use the "Improve question" link.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900