Bharathi Raja

Bharathi Raja

  • NA
  • 1.1k
  • 54.9k

Parameter is not valid c# winforms

Aug 24 2017 4:01 AM
private void picture_cat()
{
DataSet ds = Global_Class.select("select item_cat,item_image from item_cat");
PictureBox[] cat_pics = new PictureBox[50];
Label[] catlbl1 = new Label[50];
FlowLayoutPanel[] flow_image = new FlowLayoutPanel[50];
// cat_flow.Location = new Point(530, 75);
// cat_flow.Size = new Size(640, 180);
cat_flow.BackColor = Color.LightGray;
cat_flow.BorderStyle = BorderStyle.Fixed3D;
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
flow_image[i] = new FlowLayoutPanel();
flow_image[i].Name = "flw";
flow_image[i].Location = new Point(0, 0);
flow_image[i].Size = new Size(80, 80);
flow_image[i].BackColor = Color.DimGray;
flow_image[i].BorderStyle = BorderStyle.Fixed3D;
catlbl1[i] = new Label();
catlbl1[i].Size = new Size(80, 15);
catlbl1[i].Text = ds.Tables[0].Rows[i][1].ToString() + "'s";
catlbl1[i].Font = new Font("Calibra", 8, FontStyle.Bold);
catlbl1[i].ForeColor = Color.BurlyWood;
flow_image[i].Controls.Add(catlbl1[i]);
cat_pics[i] = new PictureBox();
cat_pics[i].Name = ds.Tables[0].Rows[i][1].ToString();
cat_pics[i].Size = new Size(65, 65);
string s = (string)ds.Tables[0].Rows[i][0];
byte[] data = System.Text.Encoding.ASCII.GetBytes(s);
var stream = new MemoryStream(data);
cat_pics[i].Image = Image.FromStream(stream);//This line to Parameter is not valid error throw 
cat_pics[i].SizeMode = PictureBoxSizeMode.Zoom;
//cat_pics[i].BackColor = Color.DarkGray;
cat_pics[i].Click += pic_Click;
flow_image[i].Controls.Add(cat_pics[i]);
cat_flow.Controls.Add(flow_image[i]);
}
}

Answers (1)