C#循环代码冲突? [英] C# loop code conflict?

查看:48
本文介绍了C#循环代码冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码

This is my code

      private void DragAndDropArea_Load(object sender, EventArgs e)
      {
          #region Areoload
          //load the areo into the form
          this.BackColor = Color.Black;
          MARGINS m = new MARGINS();
          m.cxLeftWidth = -1;
          m.cxRightWidth = -1;
          m.cyBottomHeight = -1;
          m.cyTopHeight = -1;
          //set all value -1 to apply glass effect to the all of visible window
          DwmExtendFrameIntoClientArea(this.Handle, m);
          //end load areo code
          #endregion
          PictureBox newpic = new PictureBox();
          newpic.Size = new Size(80, 70);
          newpic.BackColor = Color.Red;

          if (this.Name == "Dock1")
          {

              int addpicnumber = 0;
              while (addpicnumber >= Properties.Settings.Default.Dock1.Count)
              {
                  addpicnumber += 1;
                  newpic.Name = "newpic" + addpicnumber.ToString();
                  TextReader tr = new StreamReader(Properties.Settings.Default.Dock1.ToString());
                  int NumberOfLines = Properties.Settings.Default.Dock1.Count;
                  //Make our array for each line
                  string[] ListLines = new string[NumberOfLines];
                  newpic.Tag = ListLines[1] = tr.ReadLine();
                  newpic.Location = new Point(0, newpic.Location.Y + 90);
this.Controls.Add(newpic);
              }

           //problem not adding a new picturebox

          }
          }




对于某些放牧,当我将其放置在while陈述中时,picurebox不会添加,并且当我将其位置放置在while陈述中时,该位置不会移动可以使某人烦恼,请帮助我完成此操作,以便它将添加picturebox ?它的意思是在那里有2.




for some rason the picureboxes don''t add when i put it in the while statment and when i put the location in the while statment the location dosen''t move can soe one please help me make it so that it will add the picturebox? its meant to have like 2 in there

推荐答案

您的while子句期望计数为负-是这种情况吗?

两个建议

1.使其成为for循环
2.学习使用调试器
your while clause expects the count to be negative - is this the case?

Two suggestions

1. Make it a for loop
2. Learn to use the debugger


这篇关于C#循环代码冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆