C# WINFORMS Declare instances of user control -


1st of show code, simple .

filestream fs = new filestream("stock.txt", filemode.open);                 streamreader sr = new streamreader(fs, system.text.encoding.default);                  string line = "";                 string[] produtos = new string[] { };                 int count = 1;                 int = 0;                 int x = 25;                 int y = 25;                  while ((line = sr.readline()) != null)                 {                      if (!string.isnullorempty(line))                     {                           listagemprodutos mypanel = new listagemprodutos();                         mypanel.location = new point(x, y);                         this.controls.add(mypanel);                          y = y + 25;                         x = x + 25;                         i++;                      }                  } 

now problem is, everytime line != null, means have product wich display

productname productprice productquantity picture

that usercontrol has , 3 labels , picturebox, want call , fill until end of file. code works perfect main problem since im declaring instance

listagemprodutos mypanel = new listagemprodutos();

i think overwriting , , instead getting lets have 5 products 5 rows (5 times user control) last line.. think should mypanel+[i] ,so mypanel1,mypanel2 not getting way it, cause cant

listagemprodutos mypanel+[i] = new listagemprodutos();

thank reading this, , sorry grammar errors hope understand anyway !

edit: print showing problem, in simplier way. why cant have 2 or more instances of user control? why shows 1 always?

http://epvpimg.com/be8tc

romero, instead incrementing both x & y axis @ end of foreach loop, increment y axis. may control going out of window area.

just suggestion, adding control way attempting cumbersome instead try using grid control , add new rows desired values.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -