public void categorysub(int cat_id_db, int cat_id_db2, int id) { DataTable dt = new DataTable(); if (id > 0) { dt = blord.get_all_categoryGroupingById(cat_id_db, cat_id_db2, id); } else { dt = blord.get_all_category_category_id(cat_id_db, cat_id_db2); } flwpln_category.Controls.Clear(); for (int low = 0; low < dt.Rows.Count; low++) { Button[] newPanelcategory = new Button[99]; newPanelcategory[low] = new Button(); newPanelcategory[low].Name = dt.Rows[low]["category_id"].ToString(); newPanelcategory[low].Text = dt.Rows[low]["category_name"].ToString(); newPanelcategory[low].Location = System.Drawing.Point.Add(new Point(0, 4 + low * 55), new Size(50, 50)); newPanelcategory[low].Height = 98; newPanelcategory[low].Width = 114; newPanelcategory[low].AutoSizeMode = AutoSizeMode.GrowAndShrink; newPanelcategory[low].FlatStyle = FlatStyle.Flat; newPanelcategory[low].Font = new Font("Century Gothic", 10, FontStyle.Bold); //newPanelcategory[low].BackColor = ColorTranslator.FromHtml("#33A6FF"); newPanelcategory[low].ForeColor = Color.White; string image_color = dt.Rows[low]["category_color"].ToString(); if (image_color.Length > 0 && image_color != null && image_color != "") { newPanelcategory[low].BackColor = Color.FromName(image_color); newPanelcategory[low].TextAlign = ContentAlignment.TopCenter; } else { Byte[] imge_byte = (byte[])dt.Rows[low]["category_image"]; var stream = new MemoryStream(imge_byte); var image = (Bitmap)Image.FromStream(stream); var new_image = new Bitmap(image, new Size(112, 80)); newPanelcategory[low].TextAlign = ContentAlignment.BottomCenter; newPanelcategory[low].BackgroundImage = new_image; newPanelcategory[low].BackgroundImageLayout = ImageLayout.None; newPanelcategory[low].ImageAlign = ContentAlignment.TopCenter; } flwpln_category.Controls.Add(newPanelcategory[low]); newPanelcategory[low].Click += new EventHandler(newPanelcategorys_Click); //lblitem_id.Hide(); } }