当前位置:编程学习 > C#/ASP.NET >>

winform 图片列表问题

想做一个8行* 35列的图片矩阵 但是运行后发现太占用能存了 有没有什么好方法能实现少占用内存,求大神们指点啊
       while (y < 8)
            {
                for (int i = 1; i < 36; i++)
                {
                    PictureBox pb = null;
                    for (int j = 0; j < dt.Rows.Count; j++)
                    {

                        if (i * (y + 1) == int.Parse(dt.Rows[j]["LocationNum"].ToString()))
                        {
                            pb = new PictureBox();
                            pb.Width = 50;
                            pb.Height = 50;
                            pb.BackgroundImage = Resources.cdnull;
                            pb.BackgroundImageLayout = ImageLayout.Zoom;
                            Label l = new Label();
                            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
                            l.Text = "位置:" + i;
                            l.Parent = pb;
                            l.Location = new Point(0, 0);
                           
                        }
                        else
                        {
                            pb = new PictureBox();
                            pb.Width = 50;
                            pb.Height = 50;
                            pb.BackgroundImage = Resources.cdnull;
                            pb.BackgroundImageLayout = ImageLayout.Zoom;
                            pb.Name = dt.Rows[j]["Id"].ToString();
                            Label l = new Label();
                            l.Text = "位置:" + i;
                            l.Parent = pb;
                            l.Location = new Point(0, 0);
                            //cb = new CD(i.ToString(), dt.Rows[j]["Id"].ToString());
                        }
                    }

                    if (i % 35 == 0)
                    {
                        pb.Location = new Point(pb.Location.X + i * x, pb.Location.Y + y * 60);
                        y++;
                    }
                    else
                    {
                        pb.Location = new Point(pb.Location.X + i * x, pb.Location.Y + y * 60);
                    }
                    panel1.Controls.Add(pb);
                }
            } WinForm 内存 图片
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,